+ Reply to Thread
Results 1 to 2 of 2

Excel Charts to PDF

Hybrid View

Ronak.Gajjar Excel Charts to PDF 11-08-2012, 03:39 AM
patel45 Re: Excel Charts to PDF 11-08-2012, 07:06 AM
  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Ahmedabad
    MS-Off Ver
    Excel 2010
    Posts
    1

    Post Excel Charts to PDF

    Hello,
    I have excel sheet and having a chart on it i want to put a button which help to convert that chart portion in to PDF and it will save and send to email id.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Excel Charts to PDF

    an example
    Sub Create_PDF_email_It()
        Dim strSubject As String, strBody As String, strTo As String, strCC As String
        Dim Filename As String
    
        myPath = ThisWorkbook.Path & "\"
        strSubject = "Contrat de prêt Choisy à signer"
        strBody = "Bonjour, veuillez svp signer les DEUX pages du contrat de prêt et me le retourner. Merci!"
        strTo = Sheets(1).Range("Z6")
        strCC = Sheets(1).Range("Z7")
    
        Sheets("Contrat de prêt").Select
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                myPath & "Contrat de prêt " & Format(Date, "dd_mm_yyyy") & ".pdf" _
                , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
                :=False, OpenAfterPublish:=False
    
        Filename = myPath & "Contrat de prêt " & Format(Date, "dd_mm_yyyy") & ".pdf"
    
        If Filename <> "" Then
            RDB_Mail_PDF_Outlook Filename, strTo, strCC, strSubject, strBody, False
        Else
            MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
                    "Microsoft Add-in is not installed" & vbNewLine & _
                    "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
                    "The path to Save the file in arg 2 is not correct" & vbNewLine & _
                    "You didn't want to overwrite the existing PDF if it exist"
        End If
        Kill Filename
    End Sub
    
    
    Function RDB_Mail_PDF_Outlook(FileNamePDF As String, strTo As String, strCC As String, _
            strSubject As String, strBody As String, Send As Boolean)
        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 = strTo
            .CC = strCC
            .BCC = ""
            .Subject = strSubject
            .Body = strBody
            .Attachments.Add FileNamePDF
            If Send = True Then
                .Send
            Else
                .Display
            End If
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Function
    If solved remember to mark Thread as solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1