Print to PDF with file name referencing a cell

03aviator

New Member
Joined
May 31, 2011
Messages
17
I have a large workbook that I print about 11 print ranges into PDF files and I want to give a name to the saved PDF files based on a different cell in the main workbook. When running individual macros for each print range everything works fine, but when trying to run all as one macro only the first file is created and the others aren't. I am using Windows XP Professional SP 3 with MS Office Excel 2007 with Adobe Acrobat 9 Standard Edition.

This is my code:

Sub PrintPDFPage1()
'
' PrintPDFPage1 Macro
'
'
Application.Goto Reference:="Print_Page_1"
Filename = ActiveSheet.Range("A100").Value
SendKeys Filename & "{ENTER}", False
ActiveSheet.PageSetup.PrintArea = "$A$1:$O$74"
Application.ActivePrinter = "Adobe PDF on Ne01:"
ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,""Adobe PDF on Ne01:"",,TRUE,,FALSE)"
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
'
' Sheets("LBPS Bucket Report").Select
Range("A1").Select '
End Sub

each print macro is the same, just the cell refernce for the filename changes.

Any recommendations? I am just learning how to use the programming functions of MS Excel.

Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Thanks for looking at my problem!

I've check the links you provided and they are helpful, however my work computer doesn't have PDFCreator, nor can I add it without input / concern from the IT department.

My biggest problem remains with my not being able to change the filename in my save function - the first name that is used remains in effect no matter how many times the reference tries to rename it. This is even though each time it passes the following line of code the cell reference changes:

Filename = ActiveSheet.Range("A100").Value

Each pass I change the A100 to A101 then A102, etc.; but the actual name for saving is not changed when I do the "SendKeys Filename" command.
 
Upvote 0
The first run through it will save to the initial filename defined, however, the filename will remain the same even thought the cell reference (with the filename in it) changes on each pass. Therefore only Page one of my report is saved to PDF - not all eleven.
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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