Quit Word from VBA

V

vs.parthasarathy

Hi,

I am starting and quiting WORD silently from my Excel VBA. Sometimes
Word is still in the memory, it is seen in Task Manager. WORD also
loads some COM Addins. If there are no COM Addins it is quiting
always. To check all the add-ins are loaded, I added a message box
("OnStartupComplete end") in OnStartupComplete. Sometimes "Word has
started" message pops up before "OnStartupComplete end. My assumption
is "new Word.Application" is returing before all the add-ins get
loaded.

Dim w as Word.Application
set w = new Word.Application
MsgBox "Word has started"
w.Quit

Is there any other way to Quit word properly?
How to find out whether all the add-ins are loaded or not?

Environment : Office 2007.

Thanks,
VSP
 
C

Cindy M.

I am starting and quiting WORD silently from my Excel VBA. Sometimes
Word is still in the memory, it is seen in Task Manager. WORD also
loads some COM Addins. If there are no COM Addins it is quiting
always. To check all the add-ins are loaded, I added a message box
("OnStartupComplete end") in OnStartupComplete. Sometimes "Word has
started" message pops up before "OnStartupComplete end. My assumption
is "new Word.Application" is returing before all the add-ins get
loaded.

Dim w as Word.Application
set w = new Word.Application
MsgBox "Word has started"
w.Quit

Is there any other way to Quit word properly?
How to find out whether all the add-ins are loaded or not?

Environment : Office 2007.
As you don't show us all your code (OnStartupComplete and the context
it runs in is missing, for example) it's really difficult to offer any
opinion.

Loading the Ribbon, any add-ins, etc. does require a measurable amount
of time. "Of course", there is no reason for your application instance
to quit immediately after instantiating it.

What I'd try to do in your place is determine something that will cause
Word to reject a command until it has finished loading. Use On Error
Resume Next and a loop until the problem goes away, then you know Word
has finished. You might also try setting a Word.Document object to
Application.ActiveDocument and see if the object Is Nothing (if that
works, then you don't need On Error Resume Next).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top