closing Word from a macro

A

anadem

There's sure to be a better way, but is it possible to close Word from
a macro? (Not close the doc, but quit Word itself)

I need to run a (recorded+edited) macro to adjust a number of docs
which are generated by Robohelp. My naive plan is to run Word
repeatedly for each .doc from a .BAT script, thus:
DOMAC.BAT
<path>\Winword.exe /mdostuff mytext.doc

where the dostuff macro is something like:

Sub dostuff()
' stuff
ActiveDocument.Save
ActiveDocument.Close
' plus something here to shut Word down
End Sub

Alternatively, if VBS automation would make it easier to do, please
tell me how to run a macro from VBS. I found these starting & ending
vbscript fragments, which work, but don't know where to go for more ...
strDoc = "mytext.doc"
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Open strDoc, false,,false
< need to run the macro here >
WordApp.ActiveDocument.Close
WordApp.Quit
Set WordApp = Nothing

apologies if this is too raw to be bearable -- I'm trying to solve a
problem asap and don't have time to do better. (I tried to get the
macro code to run in VBS but it's taking too long.)

many thanks for any advice
 
A

anadem

Jezebel said:
Application.Quit

thanks Jezebel! is there good beginner reference to look in for
things like this (as someone who doesn't know what they're looking for,
that is!)
 
J

Jezebel

Start with the Object Browser.


thanks Jezebel! is there good beginner reference to look in for
things like this (as someone who doesn't know what they're looking for,
that is!)
 
S

Steve

:

is there good beginner reference to look in for
things like this (as someone who doesn't know what they're looking for,
that is!)

The "for Dummies" books do a good range too - but after you get familiar
with the sometimes brief explanations within F1 Help, that's the best
starting point.

Steve.
 

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