vbaword-2003

VBA Microsoft Word 2003 + MsgBox and changes to a .doc file


In MS Word 2003 can an user execute a VBA macro with inside some MsgBoxes and at the same time modify the open word document?

With an human-type example:

  1. suppose I have a .doc file opened with some text inside.
  2. I execute my macro and I wish to see the message of the first MsgBox and at the same time to change something in the .doc file without click on "Ok" in the MsgBox window.
  3. When I changed the .doc file, I wish to continue with the execution of the macro after the close of the MsgBox window with "Ok" or with "Cancel". I wish also the possibility to have more MsgBoxes opened at the same time (with always the interactive .doc file for changes during the execution of the macro).

Solution

  • Sure, just make the form modeless² when you show it:

    UserForm1.Show (False)
    

    This will show the form. Yet, you can still navigate and use the document. Yet, once you press a button within that form the VBA code attached to that button will run.

    enter image description here

    ²You can learn more about modeless at MSDN: https://msdn.microsoft.com/en-us/library/office/gg251819.aspx