Abschnit in PDF umformen und emailen

  • Word

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von swissbandit.

    Abschnit in PDF umformen und emailen

    Hallo alle, ich versuche verzweifelt nach einem VBA Code der mir einen bestimmten Abschnitt in meinem Word 2010 dokument in ein PDF exportiert, das PDF dann an ein Email anhängt (mit vor-einstellbaren Empfängern, Betreff etc) und am Schluss das PDF auf dem Rechner löscht.

    Ich habe mir einen Code zusammengepflastert der aber jeweils immer das ganze Dokument PDF-isiert und ver-Emailt. Nun brauche ich eure Hilfe. Wer kann mir helfen den Code so zu ändern, das nur ein bestimmter Abschnitt (section) des Dokuments in ein PDF umgewandelt und in eine email gepackt wird? Hier ist was ich bis jetzt habe für das ganze Dokument:

    Private Sub EmailTotalDoc_Click()
    '
    Dim vDoc As Object
    Dim vPath As String
    vPath = ActiveDocument.Path & Application.PathSeparator & "RWS.pdf"
    ActiveDocument.ExportAsFixedFormat OutputFileName:=vPath, _
    ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
    wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
    Item:=wdExportDocumentWithMarkup, IncludeDocProps:=False, KeepIRM:=True, _
    CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
    BitmapMissingFonts:=True, UseISO19005_1:=False
    Call Mail_Workbook_1(vPath)
    Kill vPath
    End Sub

    Sub Mail_Workbook_1(vPath As String)
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "Retourwarenschein"
    .Body = "Hallo, im Anhang finden Sie die Retourwarenautorisation zum besprochenen Fall"
    .Attachments.Add vPath
    .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub



    Vielen 100 Dank an all die wissenden...



    Andy

    Select Abscnitt

    Vielen Dank

    Super erster Erfolg mit folgendem Code:

    ActiveDocument.Sections(1).Range.Select
    Dim vDoc As Object
    Dim vPath As String
    vPath = ActiveDocument.Path & Application.PathSeparator & "RWS.pdf"
    ActiveDocument.ExportAsFixedFormat OutputFileName:=vPath, _
    ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
    wdExportOptimizeForPrint, Range:=wdExportSelection, ...



    Allerdings druckt es immer 2 Leere Seiten am Ende im PDF... Hab noch nicht herausgefunden warum.