I have code similar to that below to initiate an instance of Microsoft Word from within Access. How do I ensure that if an error occurs, the instance of Word gets shut down?
In the early stages of the coding when errors occurred I had to go into the Windows Task manager and manually close down the WINWORD.EXE process. Can anyone tell me which code I should include in my error handling?
Dim appWord As Object
Dim docWord As Word.Document
Dim strTemplateDoc As String
Dim CorePath As String
CorePath = GetRootPath
Set appWord = New Word.Application
strTemplateDoc = CorePath "\Template.doc"
Set docWord = appWord.Documents.Add(strTemplateDoc)
[Code to do the processing I'm doing]
appWord.Visible = False
In the early stages of the coding when errors occurred I had to go into the Windows Task manager and manually close down the WINWORD.EXE process. Can anyone tell me which code I should include in my error handling?
Dim appWord As Object
Dim docWord As Word.Document
Dim strTemplateDoc As String
Dim CorePath As String
CorePath = GetRootPath
Set appWord = New Word.Application
strTemplateDoc = CorePath "\Template.doc"
Set docWord = appWord.Documents.Add(strTemplateDoc)
[Code to do the processing I'm doing]
appWord.Visible = False