Excel vba macro print to pdf. We will adjust the code as per our. Now after installing cutepdf when you run this macro you will get a pop up to name your pdf file and select a location to save it. Set wba activeworkbook set wsa activesheet. Before you run the macro select the sheet s that you want to export to the pdf file.
First of all you need the cutepdf. To save on this excel range as pdf we will use the above mentioned generic vba code of exporting excel sheet to pdf. Vba print print in vba is very similar to the print in excel when we have important data in excel or spreadsheets then the only way to have them safe is to save them to pdf or print them for print we need to set up the print command in vba first before using it what this command does if prints or writes the data into another file. This macro consists of a single simple statement.
If you are using excel 2010 and above then excel provides you with in internal add in which allows you to save the file as pdf format. I want to printsaveexport it as a pdf using the button create pdf. You can then use the following function to print from excel. Use the test macro to get the correct syntax for the pdfcreator driver and if necessary modify the line indicated.
Those will be used to set the default file name and folder. I have already set the print area. 100 free solution to printing your excel file to pdf. This receipt covers the range a2l21.
This program acts like a printer on your computer. Sub simpleprinttopdf activesheetexportasfixedformat typexltypepdf filenamedemopdf qualityxlqualitystandard includedocpropertiesfalse ignoreprintareasfalse openafterpublishtrue end sub. Use the following code in your macro to save your file as pdf. The following sample macro named saveexcelaspdf1 is probably one of the simplest way to save an excel worksheet as pdf using vba.
Here i have designed this receipt format. This simple procedure will print the activesheet to a pdf. Excel vba print to pdf now useless.