Word文件转PDF

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/FG24151110876/article/details/90718679
Sub doc2pdf()
'
' doc2pdf 宏
'
'
Dim file As String
ChangeFileOpenDirectory "F:\我的工作文档\Word文件\"   '文件夹位置

file = Dir("*.docx")
Do Until file = ""
    On Error GoTo MyErr  '跳过
    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 wdDoNotSaveChanges
    
MyErr:     '发生异常跳过中间程序至该行语句

file = Dir
Loop

End Sub

 

展开阅读全文

没有更多推荐了,返回首页