• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel 2007 to pdf macro

venkat5652

New Member
Hi Team,

Help required from our team.

Need vba macro to save excel sheet range("A1:D30") to PDF document using Excel 2007 version.

Treat it as little bit urgent pls.

Regards
venkat
 
Code:
Option Explicit

Sub Export_Worksheet_to_PDF()

    Dim mypath As String, fname As String
    mypath = ThisWorkbook.Path
    fname = CreateObject("Scripting.FileSystemObject").GetBaseName(ThisWorkbook.Name)
    ActiveSheet.Range("A1:D30").ExportAsFixedFormat 0, mypath & "\" & fname

End Sub
 

Attachments

  • Save Range As PDF.xlsm
    17.4 KB · Views: 1
Hi Logit,

Thanks for your file.

I am facing erro in saving the document in the below piece of code.

ActiveSheet.Range("A1:D30").ExportAsFixedFormat 0, mypath & "\" & fname

"Document is not saved", i am using Excel 2007
 

Attachments

  • error screenshot.docx
    28.4 KB · Views: 1
Not certain what is occurring on your end. See attached ... works here.
 

Attachments

  • Auto Sort.xlsm
    20.4 KB · Views: 1
Back
Top