Dim application,wd
Set application = GetObject(,"word.application")
on error resume next
for each doc in application.documents
if application.documents.count > 1 then
doc.close 0
elseif application.documents.count = 1 then
doc.close 0
application.quit
else
application.quit
end if
next
Set application = Nothing
Set wd = Nothing
代码改成下面的:
Dim application,wd
Set application = GetObject(,"word.application")
on error resume next
for each doc in application.documents
if application.documents.count > 1 then
doc.close 0
elseif application.documents.count = 1 then
doc.close 0
application.quit
else
application.quit
end if
next
Set application = Nothing
Set wd = Nothing
好咧,谢谢大佬!