3 votes

Utiliser PDFMaker avec MS Outlook

Je souhaite utiliser le complément Adobe PDFMaker avec MS Outlook 2013.

Enregistrement de plusieurs courriels en pdf avec PDFMAKER

J'ai vu ce post et j'ai essayé le code, mais j'obtiens une erreur d'exécution 13 (type mismatch) à la ligne

Set pmkr2 = a.Object

Il semble que l'objet provenant de a.Object ne soit pas un objet PDFMaker. Voir cette photo J'utilise Adobe Acrobat DC 18.2816. Voici l'ensemble de mon code :

    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

Ce serait très gentil si quelqu'un pouvait m'aider, merci d'avance !

0voto

niton Points 798

Essayez d'être moins précis dans la déclaration.

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

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X