Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting Word to open in a minimized state using VBscript

228 views
Skip to first unread message

Larry

unread,
Jan 30, 2007, 2:50:05 PM1/30/07
to

The purpose of this .vbs file is to close my Word 97 when Word has gotten
frozen and then re-open it. I developed this because often the dialog box
that comes after the Close Program dialog box to complete the closing of
Word takes a long time to appear and I wanted to speed up the process. To
speed things up I also put the re-opening of Word in the same .vbs file.

Two issues.

1. Sometimes a second instance of Word opens without the existing instance
closing.

2. I can't get the new instance to open correctly in a minimized state .
When I open it in a minimized state, using oWd.WindowState = 2, it opens
minimized, but when I restore it, there is no menu bar and no toolbars!
Just the title bar. I have no idea why this happens.

Thanks for any help.

Dim oWd, doc
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
msg = "Close and restart Word?"
Title = "Close and Restart Word"
X = msgbox (msg, vBOkCancel, Title)
If X = vbOk then
oAutoIt.WinKill "Microsoft Word - ", ""
Set oWd = CreateObject("Word.Application")
Set doc = oWd.documents.add
oWd.WindowState = 2
oWd.Visible = True
'oWd.Activate
End If

Larry

unread,
Jan 30, 2007, 3:06:30 PM1/30/07
to

Here are a couple of further clues, which are strange.

If I initially open Word normalized and make it visible, and then
immediately minimize it, the minimized Word is in its correct state, with
menu bar and toolbars displayed.

Set oWd = CreateObject("Word.Application")
Set doc = oWd.documents.add

oWd.WindowState = 0
' Making it visible before minimizing it.
oWd.Visible = True
oWd.WindowState = 2

But if I open it in normalized state _without_ making it visible, and then
immediately minimize it and make it visible after minimizing it, the
minimized Word is not in correct state, it is missing menu bar and toolbars.

Set oWd = CreateObject("Word.Application")
Set doc = oWd.documents.add

oWd.WindowState = 0
oWd.WindowState = 2
' making it visible after minimizing it.
oWd.Visible = True

Why the Application visible property should control the display of the
toolbars I have no idea.


"Larry" <larry32...@att.net> wrote in message
news:OTcxXkK...@TK2MSFTNGP06.phx.gbl...

Ayush

unread,
Jan 30, 2007, 3:31:11 PM1/30/07
to
Replied to [Larry]s message :

> Here are a couple of further clues, which are strange.
>
> If I initially open Word normalized and make it visible, and then
> immediately minimize it, the minimized Word is in its correct state, with
> menu bar and toolbars displayed.
>


CreateObject("WScript.Shell").Run "word.exe",2

--
→ Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Larry

unread,
Jan 30, 2007, 5:34:20 PM1/30/07
to
Thanks.

This produces error message "System cannot find the file specified."

Also you didn't make clear how much of the existing code this replaces.
Does this handle the Visible property, the loading of a new doc, etc.?


"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:%23Zhe82K...@TK2MSFTNGP06.phx.gbl...

0 new messages