The following code runs a macro and then opens a word document -"Macros.doc" which contains an autorun macro. This inserts files into a Word template which is then saved as a new document.
When the macro has run and the new document has been created, I am left with the new document and Macros.doc open.
Can anyone please advise the code I should use to close Macros.doc but leave Word open, with the new document visible.
Best Regards
John
Code:
Dim stDocName As String
stDocName = "OutputResults"
DoCmd.SetWarnings False
DoCmd.RunMacro stDocName
DoCmd.SetWarnings True
Dim LWordDoc As String
Dim oApp As Object
LWordDoc = "c:\zzz\Macros.doc"
If Dir(LWordDoc) = "" Then
MsgBox "Document Not Found"
Else
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
oApp.Documents.Open Filename:=LWordDoc
DoCmd.Maximize
End If
When the macro has run and the new document has been created, I am left with the new document and Macros.doc open.
Can anyone please advise the code I should use to close Macros.doc but leave Word open, with the new document visible.
Best Regards
John