我想在MS Outlook 2013中使用Adobe PDFMaker加载项。
Saving multiple e-mails to pdf with PDFMAKER
我看过这篇文章并尝试了代码,但是我在行中遇到了运行时错误13(类型不匹配)
Set pmkr2 = a.Object
似乎来自a.Object的对象不是PDFMaker对象。 See this picture
我正在使用Adobe Acrobat DC 18.2816。
这是我的整个代码:
Sub ConvertToPDFWithLinks()
Dim pmkr2 As AdobePDFMakerForOffice.PDFMaker
'Set pmkr2 = Application.COMAddIns.Item(6).Object ' Assign object reference.
Set pmkr2 = Nothing
For Each a In Application.COMAddIns
If InStr(UCase(a.Description), "PDFMAKER") > 0 Then
Set pmkr2 = a.Object
Exit For
End If
Next
If pmkr2 Is Nothing Then
MsgBox "Cannot Find PDFMaker add-in", vbOKOnly, ""
Exit Sub
End If
Dim pdfname As String
pdfname = "C:\stuff\stuff\tester.pdf"
Dim stng As AdobePDFMakerForOffice.ISettings
pmkr2.GetCurrentConversionSettings stng
stng.AddBookmarks = True
stng.AddLinks = True
stng.AddTags = True
stng.ConvertAllPages = True
stng.CreateFootnoteLinks = True
stng.CreateXrefLinks = True
stng.OutputPDFFileName = pdfname
stng.PromptForPDFFilename = False
stng.ShouldShowProgressDialog = True
stng.ViewPDFFile = False
pmkr2.CreatePDFEx stng, 0
Set pmkr2 = Nothing ' Discontinue association.
End Sub
如果有人能够帮助我,这将非常好,谢谢您!
最佳答案
尝试在声明中不要太具体。
Sub getAnObject()
Dim pmkr2 As Object
Dim a As Object
Dim srchString As String
srchString = "PDFMAKER"
Set pmkr2 = Nothing
For Each a In Application.COMAddIns
Debug.Print "a.Description: " & a.Description
If InStr(UCase(a.Description), srchString) > 0 Then
If MsgBox("Is this what you want? " & vbCr & vbCr & a.Description, vbYesNo + vbQuestion) = vbYes Then
Set pmkr2 = a
Exit For
End If
End If
Next
If pmkr2 Is Nothing Then
Debug.Print "Cannot find the object using search string " & srchString
Else
Debug.Print "Object found: " & pmkr2.Description
End If
Set pmkr2 = Nothing ' Discontinue association.
End Sub