Closing Word in Automated VBA Process

To totally unlock this section 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