VBA code to convert excel to pdf and email it as attachment
Page 3 of 28 FirstFirst 1234513 ... LastLast
Results 21 to 30 of 276

Thread: VBA code to convert excel to pdf and email it as attachment

  1. #21
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,503
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    Change the line of code that is
    Code:
    .Send
    
    AND REPLACE it with 
    
    
    .Display
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

  2. #22
    New Member
    Join Date
    Jul 2013
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    New to the forum - what is the syntax for 2003

  3. #23
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,503
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    Hi and welcome to the Forum, but in future please start a new thread, if you have a question.
    To naswer your current question, the code will work in 2003
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

  4. #24
    MrExcel MVP ZVI's Avatar
    Join Date
    Apr 2008
    Location
    Sevastopol
    Posts
    3,524
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    3 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    Quote Originally Posted by jsgaggio View Post
    what is the syntax for 2003
    See Michael's code in post #2 and the top 2 lines of my comments in post #4
    Vladimir Zakharov

  5. #25
    New Member
    Join Date
    Oct 2013
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    [QUOTE=aarondesin91;3509698]Dear ZVI,

    Please help me to convert excel chart into pdf file by using macro .

  6. #26
    MrExcel MVP ZVI's Avatar
    Join Date
    Apr 2008
    Location
    Sevastopol
    Posts
    3,524
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    3 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    Quote Originally Posted by gopipallan View Post
    Dear ZVI,

    Please help me to convert excel chart into pdf file by using macro .
    Hi,
    Create chart on a sheet, save workbook in any folder and use the below code to export active sheet to the PDF file.
    Code:
    Sub SheetToPdf()
      Dim PdfFile As String
      
      ' Check compatibility of Excel version
      If Val(Application.Version) < 12 Then
        MsgBox "Export to PDF requires Excel 2007+", vbExclamation, "SheetToPdf"
        Exit Sub
      End If
      
      ' Define PDF filename
      PdfFile = ActiveWorkbook.Path & "\" & Replace(ActiveWorkbook.Name, ".xlsm", "") & "_" & ActiveSheet.Name & ".pdf"
     
      ' Export activesheet as PDF
      With ActiveSheet
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
      End With
     
      ' Report
       MsgBox "PDF file:" & vbLf & PdfFile, vbInformation, "SheetToPdf"
     
    End Sub
    Regards,
    Vladimir Zakharov

  7. #27
    New Member
    Join Date
    Oct 2013
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Re: VBA code to convert excel to pdf and email it as attachment

    Thank You for your prompt response.

    but still no luck i'm getting an error of invalid argument on below line

    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

    Thanks & regards

    Raja pallan

    Quote Originally Posted by ZVI View Post
    Hi,
    Create chart on a sheet, save workbook in any folder and use the below code to export active sheet to the PDF file.
    Code:
    Sub SheetToPdf()
      Dim PdfFile As String
      
      ' Check compatibility of Excel version
      If Val(Application.Version) < 12 Then
        MsgBox "Export to PDF requires Excel 2007+", vbExclamation, "SheetToPdf"
        Exit Sub
      End If
      
      ' Define PDF filename
      PdfFile = ActiveWorkbook.Path & "\" & Replace(ActiveWorkbook.Name, ".xlsm", "") & "_" & ActiveSheet.Name & ".pdf"
     
      ' Export activesheet as PDF
      With ActiveSheet
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
      End With
     
      ' Report
       MsgBox "PDF file:" & vbLf & PdfFile, vbInformation, "SheetToPdf"
     
    End Sub
    Regards,

  8. #28
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,503
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    You are using Excel 2007 or higher ???
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

  9. #29
    New Member
    Join Date
    Oct 2013
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    Quote Originally Posted by Michael M View Post
    You are using Excel 2007 or higher ???
    Hi,

    I am using excel 2007.


    Thanks !!!!!!!!

  10. #30
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,503
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: VBA code to convert excel to pdf and email it as attachment

    Try this one, using the old .xls file extension
    Code:
    Sub SheetToPdf()
      Dim PdfFile As String
      
      ' Check compatibility of Excel version
      If Val(Application.Version) < 12 Then
        MsgBox "Export to PDF requires Excel 2007+", vbExclamation, "SheetToPdf"
        Exit Sub
      End If
      
      ' Define PDF filename
      PdfFile = ActiveWorkbook.Path & "\" & Replace(ActiveWorkbook.Name, ".xls", "") & "_" & ActiveSheet.Name & ".pdf"
     
      ' Export activesheet as PDF
      With ActiveSheet
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
      End With
     
      ' Report
       MsgBox "PDF file:" & vbLf & PdfFile, vbInformation, "SheetToPdf"
     
    End Sub
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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