在运行excel vba代码之前,我已经手动打开了Word文档,是否可以关闭通过Excel VBA打开的特定Word文档。
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.