EmptyThenDimpathAsVariantForEachpathInGetFilePaths()DimindexOfSlash,indexOfDotAsIntegerindexOfSlash=InStrRev(path,"\")indexOfDot=InStrRev" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

使用VBA將批量的WORD文檔轉換為PDF

系統 3731 0
      Sub BatchConvertToPDF()

    Dim destFolderPath As String

    destFolderPath = GetFolderPath

    If destFolderPath <> Empty Then

        Dim path As Variant

        For Each path In GetFilePaths()

            Dim indexOfSlash, indexOfDot As Integer

            indexOfSlash = InStrRev(path, "\")

            indexOfDot = InStrRev(path, ".")

            

            Dim destFilePath As String

            destFilePath = destFolderPath + Mid(path, indexOfSlash, indexOfDot - indexOfSlash) + ".pdf"

            

            ConvertToPDF path, destFilePath

        Next path

    End If

End Sub



Function GetFilePaths()

    Dim folderPath As String

    With Application.FileDialog(msoFileDialogFilePicker)

        .Filters.Add "word文件", "*.doc; *.dotx; *.docm"

        .Title = "請擇要轉換的word文件"

        If .Show = -1 Then

            Set GetFilePaths = .SelectedItems

        End If

    End With

End Function



Function GetFolderPath()

    Dim folderPath As String

    With Application.FileDialog(msoFileDialogFolderPicker)

        .AllowMultiSelect = False

        .Title = "請選擇要存放的目錄"

        If .Show = -1 Then

            GetFolderPath = .SelectedItems(1)

        End If

    End With

End Function



Sub ConvertToPDF(srcPath As Variant, destPath As String)

    Documents.Open FileName:=srcPath, ConfirmConversions:=False, _

        ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _

        PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _

        WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""

    ActiveDocument.ExportAsFixedFormat OutputFileName:= _

        destPath, ExportFormat:= _

        wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _

        wdExportOptimizeForOnScreen, Range:=wdExportAllDocument, From:=1, To:=1, _

        Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _

        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _

        BitmapMissingFonts:=True, UseISO19005_1:=False

    ActiveDocument.Close

End Sub


    

使用VBA將批量的WORD文檔轉換為PDF


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 滦平县| 观塘区| 合阳县| 南昌市| 三江| 永川市| 拜城县| 南阳市| 荣昌县| 蒙阴县| 凌海市| 曲靖市| 晋宁县| 凯里市| 彩票| 偃师市| 清远市| 渭源县| 桐庐县| 于田县| 济南市| 丰都县| 金山区| 遵化市| 宿迁市| 尚义县| 林州市| 吉安市| 建平县| 巴彦淖尔市| 麻城市| 桂平市| 大竹县| 永和县| 高碑店市| 惠州市| 海阳市| 盖州市| 理塘县| 寻乌县| 盘锦市|