Printing workbook to PDF

plannett

New Member
Joined
Sep 15, 2009
Messages
6
Hello,
How do I print my workbook to PDF. I am close but not there yet.
Instead of posting my non working code I was hoping someone could put some code on here.
I am going to assign the macro to a button.
I would like to put the folder path in one cell U18
the filename will be in three different cells, U19, U20, U21
I need to print the workbook but only pages 1-3, there are 10+ sheets and I don't need the rest.
The print areas are already set on pages 1-3.
I would like to print to Cute PDF Writer if possible.
I believe that part is ActivePrinter:="CutePDF Writer on CPW2:"

Let me know if I missed anything or there are other questions.
Jimmy
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Application.ActivePrinter = "CutePDF Writer on CPW2:"
ActiveWorkbook.PrintOut From:=1, To:=3, Copies:=1, Preview:=False, ActivePrinter:="CutePDF Writer on CPW2:", Collate:=True, PrintToFile:=False
'fullfilename was a named range for a cell that used concatenate to put together multiple variables for the file name
SendKeys Range("fullfilename").Value & "{ENTER}", False

'----------------
'for more information
'make sure to lookup the printout method in excel 2007 help
'click the search button in excel help search and change it to developer reference.
'expression.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, IgnorePrintAreas)
'Return Value
'Variant

'expression A variable that represents a Chart object.

'Parameters

'Name Required/Optional Data Type Description
'From Optional Variant The number of the page at which to start printing. If this argument is omitted, printing starts at the beginning.
'To Optional Variant The number of the last page to print. If this argument is omitted, printing ends with the last page.
'Copies Optional Variant The number of copies to print. If this argument is omitted, one copy is printed.
'Preview Optional Variant True to have Microsoft Excel invoke print preview before printing the object. False (or omitted) to print the object immediately.
'ActivePrinter Optional Variant Sets the name of the active printer.
'PrintToFile Optional Variant True to print to a file. If PrToFileName is not specified, Microsoft Excel prompts the user to enter the name of the output file.
'Collate Optional Variant True to collate multiple copies.
'PrToFileName Optional Variant If PrintToFile is set to True, this argument specifies the name of the file you want to print to.

'Remarks
'"Pages" in the descriptions of From and To refers to printed pages — not overall pages in the sheet or workbook.
'Example
'This example prints the active sheet.
'Visual Basic for Applications
'ActiveSheet.PrintOut
'this piece of code below did not work. Adobe would read it as a corrupt document.
'PrToFileName:=Range("filepath").Value & Range("filename1").Value
'the workaround was using sendkeys
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

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