WTC_Services
asked on
Excel print multiple worksheets as one document
Hi,
I'm trying to write a macro that exports my excel document to pdf. I can do this one worksheet at a time but i wish to export specific worksheets (dependent on a table of contents) all into the one pdf file.
For example, say i have worksheets A - F, and this time round i want A,B,D and E all to be exported to the one pdf file.
Thanks
I'm trying to write a macro that exports my excel document to pdf. I can do this one worksheet at a time but i wish to export specific worksheets (dependent on a table of contents) all into the one pdf file.
For example, say i have worksheets A - F, and this time round i want A,B,D and E all to be exported to the one pdf file.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
With my last comment, I am able to highlight a specific area on a worksheet, but this still doesnt allow me to save multiple worksheets as pdf
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
teylyn,
your method allowed me to print, however when I tried to save as pdf, this method didn't work, maybe my syntax was wrong?
Sheets(Array("Sheet1", "Sheet2")).Select
Sheets("Sheet1").Activate
ActiveWindow.SelectedSheet s.ExportAs FixedForma t Type:=xlTypePDF, Filename:= _
"C:\Users\nickf\Desktop\ex perts_save as.pdf", Quality:=xlQualityStandard , _
IncludeDocProperties:=True , IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
What I need to know is how to write an if statement in the macro, so that for example if(A1="YES",Print page 1, Don't print page 1).
Could I possibly hide worksheets rather than select, then print the entire workbook?
your method allowed me to print, however when I tried to save as pdf, this method didn't work, maybe my syntax was wrong?
Sheets(Array("Sheet1", "Sheet2")).Select
Sheets("Sheet1").Activate
ActiveWindow.SelectedSheet
"C:\Users\nickf\Desktop\ex
IncludeDocProperties:=True
True
End Sub
What I need to know is how to write an if statement in the macro, so that for example if(A1="YES",Print page 1, Don't print page 1).
Could I possibly hide worksheets rather than select, then print the entire workbook?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks,
Using a combination of all three answers i've managed to write a macro that hides unnecessary sheets, then prints the whole worksheet and unhides the worksheets.
WTC
Using a combination of all three answers i've managed to write a macro that hides unnecessary sheets, then prints the whole worksheet and unhides the worksheets.
WTC
ASKER
Thanks this is a good start, the problem is that i wish to print only specific pages. I see now that if I highlight specific pages and choose "Selection" it only prints those pages.
How can I write a macro with an if statement that checks my contents page to determine which sheets to save? It's really the if and select statements that i dont know how to write.