
In your code you could just replace the lines filename = Application. If that already exists then try AwesomeData2.pdf and so on. If the cell contains "AwesomeData" then we will try and create a file in the current users desktop called AwesomeData.pdf. The value of that cell will be the base file name. Use the comments in the code to help understand what is happening. Hopefully this is self explanatory enough. Worksheets("RentalCalcs").Range("A1:N24").Select Worksheets("Rental").Range("A1:N24").Selectįilenamerentalcalcs = Path & "\" & Sheets("RentalCalcs").Range("O1") 'ThisWorkbook.Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select Path = CreateObject("WScript.Shell").specialfolders("Desktop")įilenamerental = Path & "\" & Sheets("Rental").Range("O1") I have linked the code to a commandbutton on the Rental Sheet - Private Sub CommandButton1_Click() I have changed the code and references and it now works. Worksheets("RentalCalcs").Range("A1:N24").ExportAsFixedFormat Type:=xlTypePDF, _ Worksheets("Rental").Range("A1:N24").ExportAsFixedFormat Type:=xlTypePDF, _ Title:="Select Path and Filename to save") Here is the code I have so far: Sub PrintRentalForm()įilename = Application.GetSaveAsFilename(InitialFileName:="", _įileFilter:="PDF Files (*.pdf), *.pdf", _

2, 3 in the filename based on the copy number?**
#Pdf print selection pdf#
If multiple copies of the same sheet are saved/printed to PDF can each copy have a number eg.Is there a way that the PDF file can create a folder on the users desktop and save the file with a file name based on specific cells in the sheet?.There are two things I want to do though:

I have a code that prints a selected area in a worksheet to PDF and allows user to select folder and input file name.
