• 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.

Print areas

emmatm

Member
I would like to have 2 buttons (form controls), the first button I would like to print a form (the same area each time).
The second button I would like the same print are but in a PDF document rather than a print out.
How do I do this?
 
The print area for a worksheet can be setup using the Page layout - Print Area button. Then, copy these 2 macros into a module in the Visual Basic Editor. Edit the 2nd one as needed
Code:
Sub RegularPrint()
ActiveSheet.PrintOut
End Sub

Sub PDF_Print()
Dim fPath As String, fName As String
'Where do we want to save the PDF?
fPath = "C:\My Documents\"
'What do we name the PDF?
fName = "My file.pdf"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fPath & fName
End Sub
Create two buttons of your choice (either a shape, or from Developer ribbon), Right-click and assign macros, and you're done!
 
Back
Top