word批量转PDF 利用word的宏

打开一个world ,操作说明搜索 ->输入 宏 -> 选择 查看宏 -> 创建

1、把下面代码拷贝到编辑器中
2、修改 ChangeFileOpenDirectory "D:\shares\word" '文件夹位置 为自己的文件夹
3、点击上面的启动按钮开始运行
就可以等待自动转换啦~~~

Sub word2pdf()
'
' word2pdf 宏
'
'
Dim file As String
ChangeFileOpenDirectory "D:\shares\word"   '文件夹位置

file = Dir("*.doc")
Do Until file = ""
Documents.Open FileName:=file
FileName = ActiveDocument.Name
BaseName = Left(FileName, InStrRev(FileName, ".") - 1)
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
BaseName & ".pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=False
ActiveDocument.Close

file = Dir
Loop

End Sub
image.png
image.png
image.png

你可能感兴趣的:(word批量转PDF 利用word的宏)