Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: closing Word from a macro

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

closing Word from a macro
anadem[ at ]gmail.com 07.06.2006 01:35:03
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

Re: closing Word from a macro
"Jezebel" <warcrimes[ at ]whitehouse.gov> 07.06.2006 02:17:44
Application.Quit



<anadem[ at ]gmail.com> wrote in message
news:1149644103.770170.269030[ at ]i40g2000cwc.googlegroups.com...
[Quoted Text]
> 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
>


Re: closing Word from a macro
anadem[ at ]gmail.com 07.06.2006 19:20:13
Jezebel wrote:
[Quoted Text]
> 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!)

Re: closing Word from a macro
"Jezebel" <warcrimes[ at ]whitehouse.gov> 07.06.2006 21:07:04
Start with the Object Browser.


<anadem[ at ]gmail.com> wrote in message
news:1149708013.912874.210960[ at ]u72g2000cwu.googlegroups.com...
[Quoted Text]
> Jezebel wrote:
>> 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!)
>


Re: closing Word from a macro
"Karl E. Peterson" <karl[ at ]mvps.org> 07.06.2006 21:14:54
Jezebel wrote:
[Quoted Text]
>> 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!)
>
> Start with the Object Browser.

Yep, nothing like the F1 and F2 keys!
--
Working without a .NET?
http://classicvb.org/


Re: closing Word from a macro
Steve 09.06.2006 18:25:02
"anadem[ at ]gmail.com" wrote:

is there good beginner reference to look in for
[Quoted Text]
> 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.

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net