PDA

View Full Version : Convert First Sheet in Workbook to PDF



clhare
08-09-2007, 04:58 AM
I need to convert the first worksheet in each of about 40 Excel files to a PDF using the original filename as the PDF filename. Can anyone help me do that with a macro so I don't have to do it manually?

Bob Phillips
08-09-2007, 05:03 AM
have you got some product that lets you print as PDF? If so, how does it interact with Excel?

clhare
08-09-2007, 06:56 AM
I have Adobe Acrobat 7.0 Professional. I use it to convert Word docs to PDFs, but I've never done it with Excel. I just created a macro and went through the steps of saving a worksheet as a PDF. Here's what I ended up with:


Sub SaveAsPDF()
'
' SaveAsPDF Macro
Application.ActivePrinter = "Adobe PDF on Ne01:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Adobe PDF on Ne01:", Collate:=True
End Sub



I ran this macro on one of the other Excel files and it did work--it just prompted me for the filename. So I guess I need help getting this little macro to run on all files in a specific folder using the Excel filename as the PDF filename. Is that possible?

clhare
08-09-2007, 07:05 AM
One other thing...even though I selected where I wanted the PDF to go, it doesn't show in the macro above. How do I specify the path for the PDF so it goes in the right place the next time I run this macro?

geekgirlau
08-09-2007, 07:27 PM
I know earlier versions of Acrobat you had to use a registry setting to be able to set the filename and path for the PDF file.

I'd do a google search here. I was able to successfully do this in earlier versions (have a look at the Knowledge Base) but not in version 7. If you are running Excel 2007 the PDF capability is built-in.

mdmackillop
08-09-2007, 10:44 PM
Ken has some code here (http://www.excelguru.ca/node/21), using a third party pdf creator

clhare
08-10-2007, 05:28 AM
I'll take a look at that. Thank you!