I'm trying to make a macro that exports the specified sheets as a PDF. Right now the code looks like this:
This code works, however when I try to change the "UsedRange" to "PrintArea" the code faults. Any idea how I can get it to specify the PrintArea for each sheet rather than the used range?
Thanks
Code:
Sub SaveasPDF()
fileName = Sheets("Month Formatting").Range("A8") + " PDF"
Sheets("Totals Sheet").Activate
ActiveSheet.UsedRange.Select
Sheets("Flare").Activate
ActiveSheet.UsedRange.Select
Sheets("TOX").Activate
ActiveSheet.UsedRange.Select
Sheets("Fugitive emissions").Activate
ActiveSheet.UsedRange.Select
Sheets("Tank Emissions").Activate
ActiveSheet.UsedRange.Select
ThisWorkbook.Sheets(Array("Totals Sheet", "Flare", "TOX", "Fugitive emissions", "Tank Emissions")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, fileName:= _
ThisWorkbook.Path & "/" & fileName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
This code works, however when I try to change the "UsedRange" to "PrintArea" the code faults. Any idea how I can get it to specify the PrintArea for each sheet rather than the used range?
Thanks