Quantcast
Channel: Adobe Community : Popular Discussions - Deutsche Foren
Viewing all articles
Browse latest Browse all 13341

E-Mail in Outlook über Visual Basic mit Hilfe von AdobePDFMakerforOffice erstellen

$
0
0

Ich möchte gerne aus Visual Basic eine E-Mail aus Outlook als PDF abspeichern, wobei ich auch gerne die Anhänge mit im PDF abspeichern möchte. Dazu möchte ich das Addin in Outlook über Visual Basic verwenden.

Ich verwende derzeit VisualBasix Express und Adobe Acrobat XI Version 11.0.4.

 

Ich habe aufgrund von Quelltexten im Internet nachfolgenden Code erstellt, wobei ich das Objekt bzw. das Addin in Outlook das "AdobePDFMakerforOffice" anscheind nicht finden bzw. zuordnen kann.

 

Von Visual Basic wurde folgende Fehlermeldung angezeigt bei der markierten "-------->>" Zeile angezeigt:

"Zusätzliche Informationen: Das COM-Objekt des Typs "System.__ComObject" kann nicht in den Schnittstellentyp "AdobePDFMakerForOffice.PDFMaker" umgewandelt werden. Dieser Vorgang konnte nicht durchgeführt werden, da der QueryInterface-Aufruf an die COM-Komponente für die Schnittstelle mit der IID "{1FE6F30F-4AA0-4EB5-A61C-00C14761EC3E}" aufgrund des folgenden Fehlers nicht durchgeführt werden konnte: Schnittstelle nicht unterstützt (Ausnahme von HRESULT: 0x80004002 (E_NOINTERFACE))."

 

Es gibt wohl verschiedene Möglichkeiten das Objekt zu übernehmen, aber ich bekomme immer diese Fehlermeldung. Die Meldungen zwischendurch habe ich nur zur Bestätigung, dass Outlook bzw. das AdobePDFForOffice gefunden w bzw. connectet ist hinzugefügt.

 

Weiß hier jemand Rat ?

 

Der Code lautet:

 

  

Imports System.Diagnostics

Imports System.Linq

Imports System.Reflection

Imports System.Runtime.InteropServices

Imports Microsoft.Office.Interop

Imports AdobePDFMakerForOffice

  

      

 

PrivateSub BtnEmailOutlookPdf_Click(sender AsObject, e AsEventArgs) Handles BtnEmailOutlookPdf.Click

        Dim appAdobe As AdobePDFMakerForOffice.PDFMaker

        Dim appsettings As AdobePDFMakerForOffice.ISettings

 

        Dim Result AsBoolean = EnumWindows(Callback, IntPtr.Zero)

        Dim ObjOl AsObject

        Dim myItem As Outlook.Inspector

        Dim SpeichernameMSG, SpeichernamePDF AsString

        Dim a

        Dim IndX AsInt16

 

 

        Dim objInterOL As Microsoft.Office.Interop.Outlook.Application

        Dim objSelection As Microsoft.Office.Interop.Outlook.Selection

        Dim objItems As Microsoft.Office.Interop.Outlook.Items

        Dim objMailItem As Microsoft.Office.Interop.Outlook.MailItem

 

        ' Outlook suche und Objekt übernehmen

        IfProcess.GetProcessesByName("OUTLOOK").Count() > 0 Then

 

            ' If so, use the GetActiveObject method to obtain the process and cast it to an Application object.

            objInterOL = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)

            'MsgBox("Outlook-Objekt übergeben: Erfolg")

        Else

            MsgBox("Outlook ist nicht geöffnet, bitte Outlook starten")

        EndIf

 

        'Acrobat Objekt in Outlook suchen

        With objInterOL

            Do

                IndX = IndX + 1

                If IndX > .COMAddIns.Count ThenExit Do

            LoopUntil .COMAddIns(IndX).Description = "Acrobat PDFMaker Office COM Addin"

 

            If IndX > .COMAddIns.Count Then

                MsgBox("Unable to locate Acrobat PDFMaker COM Add-In for Microsoft Office."& vbCrLf & "Please contact an MIS associate for assistance", vbCritical, "Cannot Export PDF")

            Else

                'MsgBox("My ProgID is " & .COMAddIns(1).ProgID & " and my GUID is " & .COMAddIns(1).Guid)

                If .COMAddIns(IndX).Connect Then

                    MsgBox("The add-in is connected.")

                Else

                    MsgBox("The add-in is not connected.")

                EndIf

                appAdobe = .COMAddIns(IndX).object

                MsgBox("appAdobe zugewiesen !")

            EndIf

        EndWith

 

        SpeichernamePDF = "Test.PDF"

        appAdobe.GetCurrentConversationSettings(appsettings)

        With appsettings

            .IsConversionSilent = True

            .IsAutomation = True

            .ShouldShowProgressDialog = True

            .AddTags = False

            .ConvertComments = True

            .AddBookmarks = False

            .AddLinks = False

            .OutputPDFFileName = SpeichernamePDF

            .ViewPDFFile = True

            .AttachSourceFile = False

        EndWith

        appAdobe.CreatePDFEx(appsettings, 0)

 

    EndSub


Viewing all articles
Browse latest Browse all 13341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>