Hi to all,
I need your Help.
I created a command button on my excel file and i want to save the active sheet as pdf on desktop when i click on it.
Thank you.
Hi to all,
I need your Help.
I created a command button on my excel file and i want to save the active sheet as pdf on desktop when i click on it.
Thank you.
You can do by record macro
Private Sub Btn_Click() Call macro1 End sub
"Presh Star Who has help you *For Add Reputation!! And mark case as Solve"
I have no idea about VBA, I will only write this code?
Try
Private Sub CommandButton1_Click() Dim saveLocation As String, fileName As String fileName = "myPDFFile.pdf" ' <<<< CHANGE as needed saveLocation = "C:\Users\xxxx\OneDrive\Desktop\" & fileName ' <<<< CHANGE as needed ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _ fileName:=saveLocation End Sub
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
Into sheet code:
into module:Private Sub CommandButton1_Click() Call SavePDF4Me End Sub
Check attached file.Sub SavePDF4Me() Dim MyRng As Range Dim MyFile As String Set MyRng = ActiveSheet.[A1:O21] MyFile = Environ("userprofile") & "\Desktop\MyPDFFromExcel.pdf" MyRng.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=MyFile, _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False End Sub
Happy with my answer * Add Reputation.
If You are happy with solution, please use Thread tools and mark thread as SOLVED.
Private sub CommandButton1()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
fileName:=Createobject("WScript.Shell").SpecialFolders("Desktop") & "\MyPdf.pdf"
End sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks