View Single Post
 
Old 04-01-2011, 01:54 AM
SaneMan SaneMan is offline Windows 98/ME Office 2003
Novice
 
Join Date: Jan 2011
Posts: 20
SaneMan is on a distinguished road
Default

That works perfectly! Massive thanks.

One problem though... it seems to have affected how the minimize function works on the form. We don't want the user to actual see the word document and use the form for all of the letter generation functions, so in the Initialize macro we have Word.ActiveDocument.WindowState = wdWindowStateMinimize. We also have minimize buttons on the form which minimize both the form and the word document and this is Word.ActiveWindow.WindowState - wdwindowStateMinimize.

Before I inputted your macro this worked so when we open the document it immediately loaded the userform and minimized the word document to make it inactive. It also meant when you're looking at other word documents it took the focus to them but then when you clicked on the userform document tab at the bottom it would go straight back to the userform with the 'mother' word document minimised.

Now when we load the document it still mimizes the word document correctly, but as soon as you look at another word document it maximizes the userform word document. It also stops the Minimize feature on the userform working correctly - you can click the mimize button to minimize the form, but now when you click on the tab at the bottom to re-activate the word document/userform it brings up the word document but does not re-load the userform.

Any way around this?

Many thanks again. Never would have figured it out myself!

Edit - forgot an important point. When I first made the changes you suggested and opened up the userform it did not minimize the word document. So I looked through the macros and realised Word.ActiveDocument.WindowState no longer worked. So I had to change it to Word.ActiveWindow.WindowState. Somehow adding the DocFrm as a dimension has stopped the active document window state being able to be affected. I think this is the reason when I click onto another word document it stops the userform word document from being minimized..
Reply With Quote