About You - Tools - Profile - Gallery

http://www.heelpbook.net/feed   Valid RSS (HeelpBook) - visit http://www.heelpbook.com/feed   http://www.heelpbook.com/feed

To totally unlock this article you need to Log-in

How can we close Microsoft Word (winword.exe) with out saving it in VBA code?

In general we need to:

1. First quit the application.
2. Then close the object.
3. Then set it to nothing to release it.



Set objWord = Nothing

Example Code

‘Switch to Microsoft Word so it won’t go away when you finish.

On Error Resume Next

AppActivate “Microsoft Word”

‘If Word isn’t running, start and activate it

If Err Then

Shell “C:\Program Files\Microsoft Office\Office\” & “Winword /Automation /n”, vbHide

AppActivate “Microsoft Word”<
End If

On Error GoTo 0

‘Get an Application object so you can automate Word.

Set appWord = GetObject(, “Word.Application”)

‘#### Do what you want with the Word.Application instance…

‘#### Open, for example, a document…

appWord.Documents.Open Worddoc

‘#### And now close the Word.Application instance…


Set appWord = Nothing

5.00 avg. rating (98% score) - 1 vote

Closing Word in Automated VBA Process Closing Word in Automated VBA Process
Facebook Twitter Email Plusone Linkedin Stumbleupon Delicious Digg
© 2011 - 2013 HeelpBook - Today is: 28/3/2017 Last updated: October 7, 2014 at 11:29 am Get helped -
+ +