Forum Discussion
Continuous printing with Macros possible?
Thank you for the response.
The first code you suggest would let me save them as 3 different documents (PDF)? If so, that's what my current code does. I am looking to have it print/save PDF as one continuous form as if it was all one page. That would be your second code? I am confused on how you explained you options.
If you want to save all worksheets in the workbook in one continuous PDF, try this code instead:
Sub Macro2()
ChDir "C:\Users\<UserName>\Desktop"
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Name, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End Sub
Regards
- Budman36Sep 05, 2019Brass Contributor
yes... I would like all three sheets (that my current code saves) to be saved as one PDF, NOT the entire work book. Your code would save the entire workbook.... correct?
- Haytham AmairahSep 06, 2019Silver Contributor
Hi,
I figured out a good solution using this code:
Sub Macro5() 'Save specific sheets as PDF, but all in one file. ChDir "C:\Users\Haytham\OneDrive\Desktop" Sheets(Array("Workup 1", "PO List", "Sheet2")).Copy ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ ThisWorkbook.Name, Quality:= _ xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ OpenAfterPublish:=False ActiveWorkbook.Close SaveChanges:=False End Sub
This is the explanation of the commands in the code:
- Point Excel to the location where the file will be saved
- Create a new temporary workbook consists only from the sheets that you specify
- Create a one PDF from all sheets in that workbook and save it in the Desktop
- Close the temporary workbook without saving
Before you run the code, make sure that:
- Replace this path "C:\Users\Haytham\OneDrive\Desktop" with your specific path
- Identify the sheets that you want to include in the Array function
- The name of the sheet in the Array function should be in double quotes and each name is separated from the other by a comma
Hope that helps
- Budman36Sep 06, 2019Brass Contributor
Not sure what is going on. I cannot get a file path to work. I have tried a number of different ways. Here is my last attempt. Keep giving me a "Run-time error '76': Path not found"
- Haytham AmairahSep 06, 2019Silver Contributor