VBA 宏:将 Word 文档批量转换为 PDF
Sub ToPDF() Dim i As Integer, j As Integer Dim wordApp As Word.Application Dim name As String, wordName As String Dim doc As Word.Document
Set wordApp = CreateObject("Word.Application")
For j = 1 To 2
For i = 2 To 21
wordName = "F:\任务1、602-五室-机械系统\10 验收\" & Cells(i, j).Value & ".docx"
name = "F:\任务1、602-五室-机械系统\10 验收\" & Cells(i, j).Value & ".pdf"
Set doc = wordApp.Documents.Open(wordName)
doc.ExportAsFixedFormat OutputFileName:=name, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, From:=1, to:=1, Item:=wdExportDocumentContent, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:=True, UseISO19005_1:=False
name = "F:\任务1、602-五室-机械系统\10 验收\" & Cells(i, j).Value & "-封面.pdf"
doc.ExportAsFixedFormat OutputFileName:=name, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportFromTo, From:=1, to:=1, Item:=wdExportDocumentContent, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:=True, UseISO19005_1:=False
doc.Close
Next i
Next j
wordApp.Quit
Set wordApp = Nothing
Set doc = Nothing
End Sub
原文地址: https://www.cveoy.top/t/topic/njF4 著作权归作者所有。请勿转载和采集!