【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按钮。

相关推荐
DS随心转插件1 天前
AI 导出鸭实测:Markdown TO Word 本地化转换能力深度评测,多角度拆解本地化转换真实表现
人工智能·ai·word·wps·deepseek·ai导出鸭
DS随心转插件1 天前
AI 导出鸭实操教程:Markdown 转 Word 高效协作与隐私交付实战指南
人工智能·ai·word·豆包·deepseek·ai导出鸭
【这个世界会好的】1 天前
单层PDF转双层PDF工具
pdf
AI导出鸭PC端1 天前
ChatGPT怎么生成word文档?「AI 导出鸭」解决格式丢失痛点
人工智能·ai·chatgpt·word·豆包·ai导出鸭
SunnyDays10111 天前
Java 操作 Word 超链接:添加网页、邮箱、文件和图片链接
java·word·超链接
2501_907136821 天前
批量改发票pdf名称为金额+发票号码+销售方,方便金额核对
pdf
li星野1 天前
从 PDF 到 FAISS 向量索引:构建本地 RAG 数据预处理流水线
pdf·faiss
selfboot01 天前
已知 PDF 密码,如何免费去掉密码保护并保存无密码副本
pdf
Pearson1 天前
特大pdf文件在线预览技术方案
javascript·nginx·pdf
SunnyDays10111 天前
Python 操作 Word 文档目录详解:创建、更新、提取与删除
python·word·目录