Button to print to PDF with custom file name & custom location

Snafu13

New Member
Joined
Aug 10, 2016
Messages
13
Good Afternoon,

I have gone through a decent internet searching trying to see if I can find my exact question being answered before, unfortunately I can't seem to find code that I can splice together to work for all four of the tasks I am seeking to accomplish (Button Macro, Print to PDF, Custom File Name, Custom Location).

I have been given the unfortunately repetitive task of printing a large amount of invoices from an excel sheet. The sheet is setup so that "Sheet1" holds data and "Sheet2" has a template which auto-fills data based on a drop down menu on "Sheet2".
I am seeking to print to PDF the cells A1:K25 from Sheet2 with a custom name based off A8 and to a specific location ("D:\BUSINESS\USER\Developments").

In a perfect world I would also prefer to have excel automatically select the next drop down menu item (in A8) to then populate the template and print then repeat. However, having a button to take the edge off, leaving me with only having to select the next drop down item is perfectly fine.

I would be most grateful if you can explain as much of what you are doing as possible (although you do not have to) so that I may seek to experiment with the code without pestering the forum.

Thank you kindly.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
"Sheet2" has a template which auto-fills data based on a drop down menu on "Sheet2".
Could you post the code that you use to auto fill the data on Sheet2? Also, if the source for the items in the drop down list is found in a range, what is that range? It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach screenshots (not pictures) of your sheets. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be givaen a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
In my stubbornness, I have figured out the solution to my specific problem. However, I wished to thank you for commenting so quickly.

Sub PRINT_PAGE_PDF()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim PDFPath As String
PDFPath = "D:\BUSINESS\USER\Developments\P&PC " & Range("A8").Value & Format(Now, " dd.mm.yyyy") & ".pdf"

With ActiveSheet.PageSetup
.PrintArea = "$A$1:$K$25"
End With

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFPath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,787
Messages
6,174,563
Members
452,573
Latest member
Cpiet

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