PDA

View Full Version : Solved: minimize Word automatically when last open doc is closed



Gabor
05-08-2006, 07:40 PM
I should like to create a macro which would not execute when I have more documents open and I close them one by one - until I close the very last open document and then the macro would execute.
My aim is to have the Word program open but in a minimized state after closing the last document - i.e. not to have the big gray window which actually is good for nothing but covers the whole screen.

I created the macro below but it minimizes the program each time after I close a document.

Private Sub Document_Close()
Application.WindowState = wdWindowStateMinimize
End Sub

Could somebody perhaps show me how this macro should be changed to reach my purpose?
Thank you very much.

geekgirlau
05-08-2006, 08:23 PM
Private Sub Document_Close()
If Documents.Count = 1 Then
Application.WindowState = wdWindowStateMinimize
End If
End Sub

Gabor
05-09-2006, 12:26 AM
Thank you very much for your help and the quick reply. Now it works exactly as I imagined. Thanks.
Gabor

geekgirlau
05-09-2006, 12:33 AM
My pleasure. Make sure you mark this thread as "Solved" using the "Thread Tools" option at the top of the screen.

fumei
05-09-2006, 07:52 PM
Of course this would have to be in normal.dot.....

Just being a nerd. Sorry.

geekgirlau
05-09-2006, 08:29 PM
Of course ... but you're right not to assume that everyone knows this! :doh:

fumei
05-09-2006, 10:54 PM
I think I gave up assumptions a while ago. OK...maybe not ALL assumptions...

Gabor
05-09-2006, 11:43 PM
Thank you, Gerry. It is in the normal.dot where I placed it at the beginning.