我如何在Excel中使用VBA使用附加的PDFMaker将Powerpoint保存为PDF?

问题描述 投票:1回答:1

我正在使用Excel中的VBA从Excel更新带有图表等的Powerpoint演示文稿。我想做的是使用Powerpoint中的PDFMaker加载项通过VBA代码将该演示文稿另存为PDF。我要使用该加载项的原因是,与常规的“另存为PDF”相比,PDF的质量更好。

我正在Windows 7上使用Office 2010和Adobe Acrobat XI Standard。

我的代码可以正常工作,直到到达调用CreatePDFEx方法的阶段。然后我得到错误:

“”“运行时错误'-2147023170'

自动化错误远程过程调用失败。“”“

这是我使用的代码的一部分,在代码的前面指定了“ pdfname”:

Dim pmkr As AdobePDFMakerForOffice.PDFMaker
Dim stng As AdobePDFMakerForOffice.ISettings
Dim pdfname As String
Dim a As Object

Set pmkr = Nothing ' locate PDFMaker object
For Each a In pptApp.COMAddIns
    If InStr(UCase(a.Description), "PDFMAKER") > 0 Then
    Set pmkr = a.Object
    Exit For
    End If
Next

If pmkr Is Nothing Then
    MsgBox "Cannot Find PDFMaker add-in", vbOKOnly, ""
    Exit Sub
End If

If Dir(pdfname) <> "" Then Kill pdfname

pmkr.GetCurrentConversionSettings stng
stng.AddTags = True
stng.AddLinks = True
stng.AddBookmarks = True
stng.FitToOnePage = True
stng.ConvertAllPages = True
stng.OutputPDFFileName = pdfname
stng.PromptForPDFFilename = False
stng.ShouldShowProgressDialog = True
stng.ViewPDFFile = False

pmkr.CreatePDFEx stng, 0 ' perform conversion

If Dir(pdfname) = "" Then ' see if conversion failed
    MsgBox "Could not create " & pdfname, vbOKOnly, "Conversion failed"
End If

Set pmkr = Nothing
Set stng = Nothing

End Sub

有人知道我为什么会收到此错误,对此我该怎么办?

excel vba excel-vba pdf powerpoint-vba
1个回答
0
投票

我需要执行相同的步骤。你做到了吗?

© www.soinside.com 2019 - 2024. All rights reserved.