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

    Modal or Modeless Userforms? (Word XP)

    Greetings once again. Thanks to all who've helped me (or merely offered their 2 cents) in the past. Hopefully I can receive some good guidance or advice again.

    My latest project involves a quasi-Search-And-Replace command. (Suffice it to say that I can't just use Word's own command.) What I'd like to be able to do is create a situation where a range is highlighted by the command, and the user is then prompted for an action to be performed on the selected text. But the catch is that I'd like to give the user a chance to change the highlighting before proceeding. The problem is that the regular MsgBox function (which would otherwise have been perfectly sufficient) won't let the user change the focus to the document to change the highlighted range. Similarly, a modeless UserForm won't wait until a button on the form is clicked before proceeding with the rest of the command, i.e. it won't wait until a different range is selected, although it will allow it.

    I tried building an empty while/wend right after showing the UserForm that would (I thought) wait until a condition was met (in this case, the value of the form's tag was to equal a certain value), but it kicks in so fast that the dialog box isn't even completely displayed before the code goes off in the while/wend.

    Does anyone have any suggestions? As this will make me look very good to our publishing department, I will be sure to give full credit for any help!!

    Thanks again.
    <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
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Modal or Modeless Userforms? (Word XP)

    Although it might require a significant redesign of your project, putting all of the code into the form's code module should resolve the timing issue.

    Alternatively, you could use a modal form with a "reselect" option that lets the user return to the document and then "continue" the macro. One way to implement the continue button is a custom toolbar.

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

    Re: Modal or Modeless Userforms? (Word XP)

    Just wanted to thank you for the idea. I like it when someone else looks at the problem from a different angle, which can then give rise to a very practical solution. It wasn't all that hard to move/redo the code, and it gave me an opportunity to redo some of the "what-the-heck-was-I-thinking" bits. A few Select Case's and a few new button captions and it looks as slick as Word's own Edit Find. (OK, so that's a dubious distinction, but it is a LOT easier than what I had before!)
    Thanks.
    <font face="Comic Sans MS">That's what you do in a herd; you look out for each other!</font face=comic> - Mike

Posting Permissions

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