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
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...
CreateObject("WScript.Shell").Run "word.exe",2
--
→ Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------
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...