【发布时间】:2014-09-17 11:20:59
【问题描述】:
我正在尝试让 Excel 脚本创建一个文档文件并将其保存为 pdf 文件。创建文档没有问题,但找到正确的代码将其保存为 pdf 文件似乎是一个问题。我搜索了互联网,有很多手册和相同问题的答案都归结为相同的代码:
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
ActiveDocument.Path & "\" & ActiveDocument.Name & ".pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
不知何故,这似乎对我不起作用,因为它给了我错误“未找到命名参数”。这是我的脚本(我省略了不相关的行,我确定路径和文件名存储正确)。
'Dim Word formfield values
Dim objWord As Object
Dim strDocName As String, strDocName1 As String, strDocName2 As String
Dim strMyPath As String
'Declare Word variables
Set objWord = CreateObject("word.application")
objWord.Visible = True
With objWord.activedocument
'fill in a bunch of formfields
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strMyPath & "\" & strDocName2, _
OpenAfterExport:=False
.Close
End With
我在这里做错了什么?
【问题讨论】: