Microsoft Word - UserForm Hide instead of Unload Me when looping through documents

Asked By John Wirth on 22-Jan-13 05:07 AM
Hi- I am looping through documents and editing them with a userform. The code works fine, but the 'top' document doesn't change so I can't see what I am editing. The userform is set to modal. The when the command button is clicked and the changes are applied, then the userform is hidden.
If I unload the userform, the active document is visible as I loop through each document, but I do not want to have to reload the userform for each document.

Strangely, when the changes have been made and the useform has been hidden, the next document flashes up, but once the userform is shown again, it is the original document that is visible, even though it is not the active document. I have tried using ActiveDocument.Application.WindowState to maximize the active document, but it makes no difference. The code is stored in the normal template.

Sub ProcessCSReports()
For Each aDoc In Documents
aName = aDoc.Name
aDoc.Activate
aDoc.Application.WindowState = wdWindowStateMaximize
CWS_processor.Show
Next aDoc
End Sub


I have tried stripping away all code contained in the userform activate event and also the command button click even, but this makes no difference.
The userform is set to modal as otherwise, the code loops through all the documents before the userform is shown.
Pete Bradshaw replied to John Wirth on 28-Jan-13 10:44 AM
Hi Hohn,

I'm not sure what the rest of your code is doing so can't comment. But, my understanding of modal forms is that when they are open, everything else becomes inaccessible.

Maybe you could try setting your form to popup?

Thanks

Pete