I have read several threads on the matter but my general lack of knowledge wrt VBA seems to be preventing me from adapting the answers to my situation.
I am running a macro in XL that loops through code designed to perform some calculations, paste the results to an XL tab, print that tab and open and print one of several word documents dependung upon the results. It keeps getting hung up the second time through when attempting to open the word document. It does not matter if the word document is the same as the first run or not.
Here is the code:
Dim AppWord As Word.Application
Dim mydoc As Word.Document
...
'Start Loop
...
' PRINT NOTES
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
Set mydoc = Documents.Open(Filename:="filepathandname.docx", ReadOnly:=True)
AppWord.ActivePrinter = "Printer on Ne25:"
With AppWord
.ActiveDocument.PrintOut Background:=False
.Quit SaveChanges:=False
End With
Set AppWord = Nothing
...
End Loop
TIA!
I am running a macro in XL that loops through code designed to perform some calculations, paste the results to an XL tab, print that tab and open and print one of several word documents dependung upon the results. It keeps getting hung up the second time through when attempting to open the word document. It does not matter if the word document is the same as the first run or not.
Here is the code:
Dim AppWord As Word.Application
Dim mydoc As Word.Document
...
'Start Loop
...
' PRINT NOTES
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
Set mydoc = Documents.Open(Filename:="filepathandname.docx", ReadOnly:=True)
AppWord.ActivePrinter = "Printer on Ne25:"
With AppWord
.ActiveDocument.PrintOut Background:=False
.Quit SaveChanges:=False
End With
Set AppWord = Nothing
...
End Loop
TIA!