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.

objWord.Application.Quit

objWord.Close

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…

appWord.Quit

Set appWord = Nothing

Closing Word in Automated VBA Process
  • 5.00 / 5 5
1 vote, 5.00 avg. rating (98% score)

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: 18/1/2017 Last updated: May 2, 2013 at 22:33 pm Get helped -
+ +