Windows 更新 kb4103729 后 Excel 宏停止工作

Windows 更新 kb4103729 后 Excel 宏停止工作

自 Windows 版本 1803 更新 kb4103729 以来,我用于生成 PDF 和邮寄发票的宏停止工作。这是一个包含多个命令的宏,并引用了工作表和目标文件夹(见下文)。

我查看了所有参考资料并运行了我能在这里找到的所有解决方案:删除所有 .exd 文件,并更改运行 VBA 代码的语言设置(更新会影响语言包,我正在运行荷兰语版本的 excel)。我希望有人能帮助我。

这个问题似乎只限于这个宏(我拥有的所有版本,一个用于贷方通知单,两个用于其他语言的发票,都受到影响,但其他宏不受影响)。它一直给我第二个错误框(“无法创建 PDF,可能的原因:...”)。

这是宏:

Sub Create_PDFmail() Dim 文件名作为字符串

If ActiveWindow.SelectedSheets.Count > 1 Then
    MsgBox "There is more then one sheet selected," & vbNewLine & _
           "ungroup the sheets and try the macro again"
Else

    FileName = RDB_Create_PDF(Source:=Range("A1:F39"), _
                              FixedFilePathName:="C:\Users\woute\SharePoint\CareerCoach - Admin\Boekhouding\Verkoopfacturen\CC Factuur " & ThisWorkbook.Sheets("Template").Range("Template!E11").Value & ".pdf", _
                              OverwriteIfFileExist:=True, _
                              OpenPDFAfterPublish:=False)

    'For the selection use Selection in the Source argument
    'FileName = RDB_Create_PDF(Source:=Selection)

    'For a fixed file name use this in the FixedFilePathName argument
    'FixedFilePathName:="C:\Users\Ron\Test\YourPdfFile.pdf"

    If FileName <> "" Then
        RDB_Mail_PDF_Outlook FileNamePDF:=FileName, _
                             StrTo:=ThisWorkbook.Sheets("Template").Range("Template!H2").Value, _
                             StrCC:="", _
                             StrBCC:="", _
                             StrSubject:="factuur " & ThisWorkbook.Sheets("Template").Range("Template!E11").Value, _
                             Signature:=True, _
                             Send:=False, _
                             StrBody:="<body>Beste " & Range("Template!H3").Value & ",<br><br>" & _
                                        "In bijlage vindt u de meest recente factuur voor de dienstverlening <b><i>" & Range("Template!B12").Value & ".</i></b>" & _
                                        "<br>" & "...Bunch of body text" & _
                                       </body>"

    Else
        MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
               "Microsoft Add-in is not installed" & vbNewLine & _
               "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
               "The path to Save the file in arg 2 is not correct" & vbNewLine & _
               "You didn't want to overwrite the existing PDF if it exist"
    End If
End If

子目录结束

答案1

我遇到了同样的问题,并通过执行以下操作解决了该问题:

Windows+R 并执行 %COMMONPROGRAMFILES%

然后转到“Microsoft Shared”,现在在任一 OFFICEXX 文件夹中找到 EXP_PDF.DLL 并将其复制到 OFFICE16 文件夹。

尝试你的宏。

如果它不起作用,您仍然可以在 RDB_create_PDF 函数声明中注释掉测试插件安装的行(第一个 If 块和最后一个 EndIf 块):

    Function RDB_Create_PDF(Myvar As Object, FixedFilePathName As String, _
             OverwriteIfFileExist As Boolean, OpenPDFAfterPublish As Boolean) As String
Dim FileFormatstr As String
Dim Fname As Variant

'Test to see if the Microsoft Create/Send add-in is installed.
If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
     & Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") <> "" Then

    If FixedFilePathName = "" Then
        'Open the GetSaveAsFilename dialog to enter a file name for the PDF file.
        FileFormatstr = "PDF Files (*.pdf), *.pdf"
        Fname = Application.GetSaveAsFilename("", filefilter:=FileFormatstr, _
              Title:="Create PDF")

        'If you cancel this dialog, exit the function.
        If Fname = False Then Exit Function
    Else
        Fname = FixedFilePathName
    End If

    'If OverwriteIfFileExist = False then test to see if the PDF
    'already exists in the folder and exit the function if it does.
    If OverwriteIfFileExist = False Then
        If Dir(Fname) <> "" Then Exit Function
    End If

    'Now export the PDF file.
    On Error Resume Next
    Myvar.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:=Fname, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=OpenPDFAfterPublish
    On Error GoTo 0

    'If the export is successful, return the file name.
    If Dir(Fname) <> "" Then RDB_Create_PDF = Fname
End If
End Function

如果仍然需要的话,希望这会有所帮助。

相关内容