Reputation: 237
Before running the excel vba code, I have opened the Word document manually, is it possible to close that particular Word Document which is opened through Excel VBA
Upvotes: 0
Views: 715
Reputation: 17647
Assuming you don't already have a hook on the Word app, something like this should do the trick:
Set wordApp = GetObject(, "Word.Application")
For Each wdDoc In wordApp.Documents
If wdDoc.Name = "close_me.docx" Then '// rename to your doc
wdDoc.Close SaveChange:=False '// change to true if required
DoEvents
Exit For
End If
Next
Upvotes: 2