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

相关推荐
:mnong7 小时前
附图报价系统设计分析5
electron·pdf·vue·cad·dwg·定额
tanis_207718 小时前
DeepSeek-TUI 也能读 PDF 了:Skill + MinerU CLI 终端文档解析实战
人工智能·后端·深度学习·pdf·csdn开发云
黑咩狗夜.cm1 天前
(aspose.words .net)内容分别固定在一行左右俩端
c#·word·.net
w2018002 天前
一至六年级下册数学第五单元测试卷(人教版+苏教版)
pdf
E_ICEBLUE2 天前
如何提取 Word 文档中的表格并导出为 Excel(Python 教程)
python·word·excel
IT策士2 天前
Python Word操作:从入门到精通
python·c#·word
w2018002 天前
人教版小学一至六年级下册语文期中考试试卷PDF可打印
pdf
aaaffaewrerewrwer2 天前
一个功能非常完整的在线 Word Search Puzzle(单词搜索)网站推荐:支持自定义出题、打印与多语言
游戏·word·个人开发
w2018002 天前
小学一至六年级下册数学期中考试试卷PDF(人教版+苏教版+冀教版+北师版)
pdf
yivifu2 天前
使用PyMuPDF基于对PDF文档内容的分析自动识别并删除PDF文件中的水印
python·pdf·pymupdf·去水印