我正在尝试将选择内容复制到新文档,然后将其导出为PDF,但是出现了我无法解决的错误。
在网上,ActiveWindow.Close False
我被告知
运行时错误“ 5479”:
您无法关闭Microsoft Word,因为已打开一个对话框。单击确定,切换到单词,然后关闭对话框。
除非导出到PDF操作触发了一个对话框,否则我不知道将打开哪个对话框。
任何人都可以阐明一下吗?谢谢。
'** Copy the selection *'
Selection.Copy
'** Create a new document to paste the copied text into *'
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
'** Paste the copied text *'
Selection.PasteAndFormat (wdUseDestinationStylesRecovery)
'** Change the location of the file open directory *'
ChangeFileOpenDirectory OpenDirectory
'** Export the document to PDF *'
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
OpenDirectory & "\ZENworks.pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
'** Close the new document *'
ActiveWindow.Close False
CopyToNewDocument = True
应该ActiveDocument.Close
改为ActiveWindow.Close
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句