VBA save to PDF

buffalobill

New Member
Joined
Mar 25, 2010
Messages
2
Hi everyone, I don't have any experience with VBA but I need to use it on a payroll spreadsheet. What a need to do is have a button that saves R2:AA47 in the sheet called Payslips to a PDF on my desktop, I would also like to have the PDF named by the payslip number which is in cell Z6......is this possible by using a simple button? Any help would be greatly appreciated
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
.
VBA Code:
Option Explicit

Sub SveRngPDF()

Dim Today As Date
Sheets("Payslips").Range("R2:AA47").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\?????\Desktop\" & Sheets("Payslips").Range("Z6").Value & " ", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
    
End Sub


See if the above works for your system. NOTE: change the path section ???? to your computer name.
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,255
Members
448,879
Latest member
oksanana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top