【MOMO_Tips】批量将word转换为PDF格式

批量将word转换为PDF格式

1.打开文件-->选项-->自定义功能区-->开发工具-->确定

2.点开开发工具,选择第一个visual basic

3.进入页面后找到插入-->模块,就可以看到这样的画面之后将下列vba代码复制粘贴到模块中

python 复制代码
Sub ConvertWordsToPdfs()
'Updated by Extendoffice 20181123
    Dim xIndex As String
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Dim xNewName As String
    Dim xFileName As String
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    If xDlg.Show <> -1 Then Exit Sub
    xFolder = xDlg.SelectedItems(1) + "\"
    xFileName = Dir(xFolder & "*.*", vbNormal)
    While xFileName <> ""
        If ((Right(xFileName, 4)) <> ".doc" Or Right(xFileName, 4) <> ".docx") Then
            xIndex = InStr(xFileName, ".") + 1
            xNewName = Replace(xFileName, Mid(xFileName, xIndex), "pdf")
            Documents.Open FileName:=xFolder & xFileName, _
                ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _
                PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
                WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
                wdOpenFormatAuto, XMLTransform:=""
            ActiveDocument.ExportAsFixedFormat OutputFileName:=xFolder & xNewName, _
                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
        End If
        xFileName = Dir()
    Wend
End Sub


4.按 F5 键或点击上面的运行来运行代码,会弹出浏览对话框,请选择包含要转换为pdf文件的Word文档的文件夹,然后单击OK按钮。

相关推荐
徐小夕@趣谈前端1 小时前
拒绝重复造轮子?我们偏偏花365天,用Vue3写了款AI协同的Word编辑器
人工智能·编辑器·word
kingwebo'sZone3 小时前
C#使用Aspose.Words把 word转成图片
前端·c#·word
科技D人生6 小时前
Vue.js 学习总结(20)—— Vue-Office 实战:word、pdf、excel、ppt 多种文档的在线预览
vue.js·word·vue-pdf·stylesheet·docx-preview·vue-office
Java面试题总结21 小时前
基于 Java 的 PDF 文本水印实现方案(iText7 示例)
java·python·pdf
傻啦嘿哟1 天前
Python操作PDF页面详解:删除指定页的完整方案
开发语言·python·pdf
weixin_416660071 天前
技术分析:豆包生成带公式文案导出Word乱码的底层机理
人工智能·word·豆包
骆驼爱记录1 天前
Word样式库不显示的8种修复方法
word·wps·新人首发
苍煜1 天前
超简单 poi-tl 学习博客:从0到1掌握Word生成(无需模板+模板填充)
学习·word
请为小H留灯1 天前
Word论文 封面、目录、页码设置步骤!(2026详细版教程)
毕业设计·word·论文格式
m5655bj1 天前
使用 C# 修改 PDF 页面尺寸
java·pdf·c#