Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Mar 2003
    Location
    Elkins Park, Pennsylvania, USA
    Posts
    325
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to Close Dialog Boxes (Office XP/2003)

    Hi all. I would like to get some advice or guidance on how to approach this problem:

    I have a document with protected sections. The document has code (a class module) that checks for a selection change and turns on Document Protection (thereby moving the cursor out of the protected section) if the user tries to click in a section where .ProtectedForForms = True.

    The problem that I'm now trying to deal with is that the cursor will sometimes land in a protected section in response to a dialog box (e.g. Edit: Find). At those times, the code recognizes and traps the selection change, but the act of turning on Document Protection (if it isn't already on) throws an error because a dialog box is open. If Edit: Find or Edit: Replace were the only actions that I'd have to deal with, that would be easy enough to deal with. But there are probably numerous dialog boxes that would trigger the problem.

    Therefore, I was wondering if there was a way to check if ANY dialog boxes are open in the active window, and if so, can they be closed automatically? Maybe there is a contiguous range of error (Err) values that would indicate "Can't do that while a dialog box is open"? Something to do with the Main Story not being active?
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

  2. #2
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to Close Dialog Boxes (Office XP/2003)

    I ran into the same kind of problems. I tackled it with a global variable blnProtect, default set to True. The selection change event tests this variable. If set to True, the doc gets protected when the cursor is in a protected section and if set to False, it does not. So by trial and error you have to learn when to set this variable to False. Don't forget to set it back to True before you leave the selection change event!
    This worked ok in not too complex templates. But because of the hassle, I eventually returned to the oldfashioned way to cope with protected documents. Occasionally I still use the method with selection change, but only in simple templates with not much functionality.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •