我使用主要录制的宏来保存所选文本,文件名应为标题。我尝试了以下代码:
Sub Makro5()
Dim flnNm As String
Selection.Copy
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
Selection.PasteAndFormat (wdFormatOriginalFormatting)
ChangeFileOpenDirectory _
"\\ess\Shared Folders\V3\Handuch\"
' flnNm = "PROZESSE"
flnNm = ActiveDocument.Paragraphs(1).Range.Text
ActiveDocument.ExportAsFixedFormat OutputFileName:=flnNm, _
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
End Sub
当我直接输入注释行(flnNm)中的名称时,一切正常。但是,当我尝试使用段落的文本时,我收到错误消息:无效的文件名-2147467259(80004005)。 当我调试宏时,flnNm的内容似乎没问题。