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

相关推荐
5134959216 小时前
在Vue.js项目中使用docx和file-saver实现Word文档导出
前端·vue.js·word
乐迁~19 小时前
如何使用html2canvas和jsPDF库来解决PDF导出时分页内容截断问题(下--表格行截断处理)
pdf·js
拆房老料19 小时前
实战复盘:自研 Office / PDF 文档处理平台的高坑预警与 AI Agent 时代架构思考
人工智能·架构·pdf·编辑器·开源软件
开开心心就好19 小时前
PDF密码移除工具,免费解除打印编辑复制权限
java·网络·windows·websocket·pdf·电脑·excel
缺点内向21 小时前
C# 高效统计 Word 文档字数:告别手动,拥抱自动化
c#·自动化·word
非凡ghost1 天前
批量转双层PDF(可识别各种语言)
windows·学习·pdf·软件需求
wtsolutions1 天前
Sheet-to-Doc Supports JSON and JSONL: New Way to Batch Generate Word Documents
json·word·batch
乐迁~1 天前
前端PDF导出完全指南:JSPDF与HTML2Canvas深度解析与实战(上)
前端·pdf
问道飞鱼2 天前
【大模型学习】词嵌入(Word Embedding)深度解析:从符号到向量的语义映射
word·embedding·词嵌入
筱歌儿2 天前
TinyMCE-----word表格图片进阶版
开发语言·javascript·word