Home

Continuous printing with Macros possible?

%3CLINGO-SUB%20id%3D%22lingo-sub-836659%22%20slang%3D%22en-US%22%3EContinuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-836659%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20it%20possible%20to%20print%20multiple%20pages%20without%20stoping%20for%20each%20page%3F%20%26nbsp%3BI%20have%20a%20print%20command%20that%20prints%20three%20different%20sheets%20in%20PDF%2C%20but%20stops%20at%20the%20beginning%20of%20each%20sheet%20and%20requires%20me%20to%20save%20that%20corresponding%20sheet%20as%20a%20different%20name.%20%26nbsp%3BI%20would%20like%20it%20just%20to%20print%20one%20continuous%20report.%20%26nbsp%3B%20This%20is%20my%20coding.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20Macro1()%3C%2FP%3E%3CP%3E'%3C%2FP%3E%3CP%3E'%20Macro1%20Macro%3C%2FP%3E%3CP%3E'%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E'%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ActiveWindow.SelectedSheets.PrintOut%20Copies%3A%3D1%2C%20Collate%3A%3DTrue%2C%20_%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IgnorePrintAreas%3A%3DFalse%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Sheets(%22Workup%201%22).Select%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ActiveWindow.SelectedSheets.PrintOut%20Copies%3A%3D1%2C%20Collate%3A%3DTrue%2C%20_%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IgnorePrintAreas%3A%3DFalse%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Sheets(%22PO%20List%22).Select%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ActiveWindow.SelectedSheets.PrintOut%20Copies%3A%3D1%2C%20Collate%3A%3DTrue%2C%20_%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IgnorePrintAreas%3A%3DFalse%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-836659%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-836895%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-836895%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380356%22%20target%3D%22_blank%22%3E%40Budman36%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20just%20want%20to%20save%20each%20sheet%20of%20them%20as%20PDF%2C%20you%20can%20use%20this%20code%20instead%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-css%22%3E%3CCODE%3ESub%20Macro1()%0A'In%20the%20below%20line%20type%20the%20full%20path%20of%20the%20location%20you%20want%20to%20save%20in%0AChDir%20%22C%3A%5CUsers%5C%3CUSERNAME%3E%5CDesktop%22%0A%0A%20%20%20%20ActiveSheet.ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%0A%20%20%20%20%20%20%20%20ActiveSheet.Name%2C%20Quality%3A%3DxlQualityStandard%2C%20_%0A%20%20%20%20%20%20%20%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20OpenAfterPublish%3A%3D%20_%0A%20%20%20%20%20%20%20%20False%0A%0A%20%20%20%20Sheets(%22Workup%201%22).Select%0A%0A%20%20%20%20ActiveSheet.ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%0A%20%20%20%20%20%20%20%20ActiveSheet.Name%2C%20Quality%3A%3DxlQualityStandard%2C%20_%0A%20%20%20%20%20%20%20%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20OpenAfterPublish%3A%3D%20_%0A%20%20%20%20%20%20%20%20False%0A%0A%20%20%20%20Sheets(%22PO%20List%22).Select%0A%0A%20%20%20%20ActiveSheet.ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%0A%20%20%20%20%20%20%20%20ActiveSheet.Name%2C%20Quality%3A%3DxlQualityStandard%2C%20_%0A%20%20%20%20%20%20%20%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20OpenAfterPublish%3A%3D%20_%0A%20%20%20%20%20%20%20%20False%0AEnd%20Sub%3C%2FUSERNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%20to%20run%20the%20command%20on%20all%20sheets%20in%20the%20workbook%2C%20you%20can%20encapsulate%20it%20in%20a%20For-Each-Loop%20as%20follows%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-css%22%3E%3CCODE%3ESub%20Macro1()%0AChDir%20%22C%3A%5CUsers%5C%3CUSERNAME%3E%5CDesktop%22%0A%20%20%20%20For%20Each%20Sheet%20In%20Sheets%0A%20%20%20%20%20%20%20%20Sheet.ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%0A%20%20%20%20%20%20%20%20%20%20%20%20Sheet.Name%2C%20Quality%3A%3DxlQualityStandard%2C%20_%0A%20%20%20%20%20%20%20%20%20%20%20%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20OpenAfterPublish%3A%3D%20_%0A%20%20%20%20%20%20%20%20%20%20%20%20False%0A%20%20%20%20Next%20Sheet%0AEnd%20Sub%3C%2FUSERNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-837116%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-837116%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20response.%3C%2FP%3E%3CP%3EThe%20first%20code%20you%20suggest%20would%20let%20me%20save%20them%20as%203%20different%20documents%20(PDF)%3F%20%26nbsp%3BIf%20so%2C%20that's%20what%20my%20current%20code%20does.%20%26nbsp%3BI%20am%20looking%20to%20have%20it%20print%2Fsave%20PDF%20as%20one%20continuous%20form%20as%20if%20it%20was%20all%20one%20page.%20%26nbsp%3BThat%20would%20be%20your%20second%20code%3F%20%26nbsp%3BI%20am%20confused%20on%20how%20you%20explained%20you%20options.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-837157%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-837157%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380356%22%20target%3D%22_blank%22%3E%40Budman36%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20first%20code%20saves%20the%20specific%20sheets%20as%20PDF%2C%20each%20one%20in%20a%20separate%20PDF%20file%20which%20are%20the%20currently%20selected%20sheet%2C%20sheet%20Workup%201%2C%20and%20sheet%20PO%20List.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20second%20code%20does%20the%20same%20thing.%20but%20the%20difference%20is%20that%20it%20loops%20through%20each%20sheet%20in%20the%20workbook%20and%20save%20it%20as%20PDF%20regardless%20of%20the%20sheet%20names%20and%20count.%20It%20also%20names%20the%20PDF%20as%20the%20original%20sheet%20name%20in%20Excel.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3ENone%20of%20them%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3Eprintout%20the%20PDFs%2C%20they%20just%20save%20as%20PDF%20locally!%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-837169%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-837169%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380356%22%20target%3D%22_blank%22%3E%40Budman36%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%20to%20save%20all%20worksheets%20in%20the%20workbook%20in%20one%20continuous%20PDF%2C%20try%20this%20code%20instead%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-css%22%3E%3CCODE%3ESub%20Macro2()%0AChDir%20%22C%3A%5CUsers%5C%3CUSERNAME%3E%5CDesktop%22%0A%20%20%20%20ActiveWorkbook.ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%0A%20%20%20%20%20%20%20%20ThisWorkbook.Name%2C%20Quality%3A%3D%20_%0A%20%20%20%20%20%20%20%20xlQualityStandard%2C%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20_%0A%20%20%20%20%20%20%20%20OpenAfterPublish%3A%3DFalse%0AEnd%20Sub%3C%2FUSERNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-839467%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-839467%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eyes...%20I%20would%20like%20all%20three%20sheets%20(that%20my%20current%20code%20saves)%20to%20be%20saved%20as%20one%20PDF%2C%20NOT%20the%20entire%20work%20book.%20%26nbsp%3BYour%20code%20would%20save%20the%20entire%20workbook....%20correct%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-840235%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-840235%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380356%22%20target%3D%22_blank%22%3E%40Budman36%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20the%20code%20would%20save%20the%20entire%20workbook!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-840264%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-840264%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380356%22%20target%3D%22_blank%22%3E%40Budman36%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20figured%20out%20a%20good%20solution%20using%20this%20code%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-css%22%3E%3CCODE%3ESub%20Macro5()%0A'Save%20specific%20sheets%20as%20PDF%2C%20but%20all%20in%20one%20file.%0A%0AChDir%20%22C%3A%5CUsers%5CHaytham%5COneDrive%5CDesktop%22%0ASheets(Array(%22Workup%201%22%2C%20%22PO%20List%22%2C%20%22Sheet2%22)).Copy%0A%20%20%20%20ActiveWorkbook.ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%0A%20%20%20%20%20%20%20%20ThisWorkbook.Name%2C%20Quality%3A%3D%20_%0A%20%20%20%20%20%20%20%20xlQualityStandard%2C%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20_%0A%20%20%20%20%20%20%20%20OpenAfterPublish%3A%3DFalse%0AActiveWorkbook.Close%20SaveChanges%3A%3DFalse%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20the%20explanation%20of%20the%20commands%20in%20the%20code%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3EPoint%20Excel%20to%20the%20location%20where%20the%20file%20will%20be%20saved%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3ECreate%20a%20new%20temporary%20workbook%20consists%20only%20from%20the%20sheets%20that%20you%20specify%3C%2FLI%3E%3CLI%3ECreate%20a%20one%20PDF%20from%20all%20sheets%20in%20that%20workbook%20and%20save%20it%20in%20the%20Desktop%3C%2FLI%3E%3CLI%3EClose%20the%20temporary%20workbook%20without%20saving%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBefore%20you%20run%20the%20code%2C%20%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3Emake%20sure%20that%3A%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CUL%3E%3CLI%3EReplace%20this%20path%20%22C%3A%5CUsers%5CHaytham%5COneDrive%5CDesktop%22%20with%20your%20specific%20path%3C%2FLI%3E%3CLI%3EIdentify%20the%20sheets%20that%20you%20want%20to%20include%20in%20the%20Array%20function%3C%2FLI%3E%3CLI%3EThe%20name%20of%20the%20sheet%20in%20the%20Array%20function%20should%20be%20in%20double%20quotes%20and%20%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3Eeach%20name%20is%20separated%20from%20the%20other%20by%20a%20comma%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-840885%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-840885%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENot%20sure%20what%20is%20going%20on.%20%26nbsp%3BI%20cannot%20get%20a%20file%20path%20to%20work.%20%26nbsp%3BI%20have%20tried%20a%20number%20of%20different%20ways.%20%26nbsp%3BHere%20is%20my%20last%20attempt.%20%26nbsp%3BKeep%20giving%20me%20a%20%22Run-time%20error%20'76'%3A%20Path%20not%20found%22%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20770px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F130456i7F90757B5E35C404%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22SnipImage.JPG%22%20title%3D%22SnipImage.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-840944%22%20slang%3D%22en-US%22%3ERe%3A%20Continuous%20printing%20with%20Macros%20possible%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-840944%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380356%22%20target%3D%22_blank%22%3E%40Budman36%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20error%20is%20expected%20because%20you%20didn't%20change%20this%20placeholder%20%3CSTRONG%3E%3CUSERNAME%3E%3C%2FUSERNAME%3E%3C%2FSTRONG%3Ein%20the%20path%20with%20the%20existing%20user%20name%20in%20your%20computer!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20best%20way%20to%20get%20the%20path%20of%20any%20file%20or%20folder%20is%20to%20press%20%3CA%20href%3D%22https%3A%2F%2Fwww.pcworld.com%2Farticle%2F251406%2Fwindows-tips-copy-a-file-path-show-or-hide-extensions.html%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3EShift%20and%20mouse%20Right-click%3C%2FA%3Esimultaneously.%3C%2FP%3E%3CP%3EThis%20will%20add%20a%20new%20option%20in%20the%20right-click%20menu%20called%20(Copy%20as%20path).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20you%20can%20replace%20the%20path%20line%20with%20the%20below%20which%20will%20save%20the%20PDF%20in%20the%20same%20path%20that%20the%20original%20workbook%20was%20saved%20in!%3C%2FP%3E%3CP%3E%3CSTRONG%3EChDir%20ThisWorkbook.Path%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-css%22%3E%3CCODE%3ESub%20Macro5()%0A'Save%20specific%20sheets%20as%20PDF%2C%20but%20all%20in%20one%20file.%0A%0AChDir%20ThisWorkbook.Path%0A%0ASheets(Array(%22Sheet1%22%2C%20%22PO%20List%22)).Copy%0A%20%20%20%20ActiveWorkbook.ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%0A%20%20%20%20%20%20%20%20ThisWorkbook.Name%2C%20Quality%3A%3D%20_%0A%20%20%20%20%20%20%20%20xlQualityStandard%2C%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20_%0A%20%20%20%20%20%20%20%20OpenAfterPublish%3A%3DFalse%0AActiveWorkbook.Close%20SaveChanges%3A%3DFalse%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E
Budman36
Contributor

Is it possible to print multiple pages without stoping for each page?  I have a print command that prints three different sheets in PDF, but stops at the beginning of each sheet and requires me to save that corresponding sheet as a different name.  I would like it just to print one continuous report.   This is my coding.

 

Sub Macro1()

'

' Macro1 Macro

'

 

'

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _

        IgnorePrintAreas:=False

    Sheets("Workup 1").Select

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _

        IgnorePrintAreas:=False

    Sheets("PO List").Select

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _

        IgnorePrintAreas:=False

End Sub

9 Replies

@Budman36

 

Hi,

 

If you just want to save each sheet of them as PDF, you can use this code instead:

Sub Macro1()
'In the below line type the full path of the location you want to save in
ChDir "C:\Users\<UserName>\Desktop"

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        ActiveSheet.Name, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        False

    Sheets("Workup 1").Select

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        ActiveSheet.Name, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        False

    Sheets("PO List").Select

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        ActiveSheet.Name, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
        False
End Sub

 

If you want to run the command on all sheets in the workbook, you can encapsulate it in a For-Each-Loop as follows:

Sub Macro1()
ChDir "C:\Users\<UserName>\Desktop"
    For Each Sheet In Sheets
        Sheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            Sheet.Name, Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
            False
    Next Sheet
End Sub

 

Hope that helps

@Haytham Amairah 

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.

 

@Budman36

 

The first code saves the specific sheets as PDF, each one in a separate PDF file which are the currently selected sheet, sheet Workup 1, and sheet PO List.

 

The second code does the same thing. but the difference is that it loops through each sheet in the workbook and save it as PDF regardless of the sheet names and count. It also names the PDF as the original sheet name in Excel.

 

None of them printout the PDFs, they just save as PDF locally!

@Budman36

 

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

@Haytham Amairah 

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?

@Budman36

 

Yes, the code would save the entire workbook!

@Budman36

 

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

@Haytham Amairah 

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"

SnipImage.JPG

@Budman36

 

The error is expected because you didn't change this placeholder <UserName> in the path with the existing user name in your computer!

 

The best way to get the path of any file or folder is to press Shift and mouse Right-click simultaneously.

This will add a new option in the right-click menu called (Copy as path).

 

Also, you can replace the path line with the below which will save the PDF in the same path that the original workbook was saved in!

ChDir ThisWorkbook.Path

 

Sub Macro5()
'Save specific sheets as PDF, but all in one file.

ChDir ThisWorkbook.Path

Sheets(Array("Sheet1", "PO List")).Copy
    ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        ThisWorkbook.Name, Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
ActiveWorkbook.Close SaveChanges:=False
End Sub

 

 

Regards

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies