Macro to PDF all sheets automatically

jaxidern

New Member
Joined
Sep 12, 2010
Messages
10
Hi all Gurus,

Hope you can help me out with this simple request. Thanks

System:
1. Excel 2003
2. Acrobat Acrobat 9 Standard

Issue:
I have to do an admin job of filtering files every week!!! There are 20 tabs, and i have to pdf them one-by-one base on each of the tab names. Can someone lessen my misery, thanks!!!

Requirements:
Macro should pdf all sheets in the excel file according the the tabs available.
The front part of the PDF name should carry the file name then followed by the sheet name behind. Example, filename is called test. First sheet is called apple, second sheet called orange and so on.... So the pdf file of the first sheet should be called <<TEST apple.pdf>> and the second sheet called <<TEST orange.pdf>>
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hello

Try the code below. Please note that it was tested with Excel 2007 & Adobe Reader 10.1.1

Code:
Sub SaveAsPDF()

Dim dir_s$, tail$, sht As Worksheet

dir_s = ThisWorkbook.Path
ChDir dir_s
dir_s = dir_s & "\" & ThisWorkbook.Name
For Each sht In ThisWorkbook.Worksheets
    tail = dir_s & "_" & sht.Name & ".pdf"
    sht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=tail, quality:=xlQualityStandard, _
    includedocproperties:=True, ignoreprintareas:=False, openafterpublish:=False
Next
    
End Sub
 
Upvote 0
Hi Worf,

Thanks for sharing. I receive this prompt: "compile error: Method or data member not found" when i try running the macro. It was highlighting "ExportAsFixedFormat" in the code as well. Not sure where the issue is.. thanks
 
Upvote 0
I receive this prompt: "compile error: Method or data member not found" when i try running the macro. It was highlighting "ExportAsFixedFormat" in the code as well.

Hi

Assuming you are using Excel 03, this probably means this method doesn't exist in this version, at least with this name. I don't have access to Excel 03 right now, and don't quite remember how it handles PDFs. As I said, my macro was developed in Excel 07.

Can you use a Office 07 machine to perform that task?
 
Upvote 0
Hi....

ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"

This might help....

or

if you have pdf writer (when you go for file save as option),

ActiveWorkbook.SaveAs Filename:= _
"D:\Document.pdf", _
FileFormat:=pdf, CreateBackup:=False

Regards,

MGM
 
Upvote 0
Hi....

ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"

This might help....

or

if you have pdf writer (when you go for file save as option),

ActiveWorkbook.SaveAs Filename:= _
"D:\Document.pdf", _
FileFormat:=pdf, CreateBackup:=False

Regards,

MGM
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
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