One may not use a Shul as a shortcut (Shulchan Aruch OC 151:5). If one must enter a Shul to call his friend, he should say some pesukim or even sit there for a few moments (Kitzur Shulchan Aruch 13:3).
I know of a number of Shuls (and batei medrashot) which have rooms branching off from the Shul, which are only accessible by passing through the Shul. Is it a problem to go to those rooms because he's using it as a "shortcut"? Must he avoid that issue by pausing in the Shul and saying a few pesukim? Or is it not a problem at all, since he is not disrespecting the Shul since the room is only accessible by going through the shul?