excel - Changing VBA that creates Multiple PDFs to Single PDF -
the code below working great create pdfs worksheet 3 worksheet named "post" while ignoring hidden sheets. creates individual pdf each of these worksheets. linked shape users click , prompted select folder save pdfs.
i'm trying alter code below exact same thing except create single pdf each visible worksheet between sheet 3 , "post".
i've been massaging code around while , wondering if knows best way accomplish this?
sub saveallpdf() dim integer dim fname string dim tabcount long tabcount = sheets("post").index 'set tabcount last cell want pdf dim dialog filedialog dim path string set dialog = application.filedialog(msofiledialogfolderpicker) dialog.allowmultiselect = false if dialog.show = -1 path = dialog.selecteditems(1) ' begin loop. = 3 tabcount 'set = number of first sheet want pdf in order left right tabcount if sheets(i).visible <> xlsheetvisible else sheets(i) fname = .range("c15") & " " & .range("e13") & "-" & .range("b1") 'the fname above equaling cells pdf's filename 'the folder directory below pdf files saved .exportasfixedformat type:=xltypepdf, filename:=path & "\" & fname, quality:=xlqualitystandard, _ includedocproperties:=true, ignoreprintareas:=false, openafterpublish:=false end end if next call shell("explorer.exe" & " " & path & "\", vbnormalfocus) 'this opens folder pdfs saved end if end sub
if select multiple worksheet tabs mouse, select print, print them 1 print job, give try in code:
sub saveallpdf() dim integer dim fname string dim tabcount long dim asheetnames variant tabcount = sheets("post").index 'set tabcount last cell want pdf dim dialog filedialog dim path string set dialog = application.filedialog(msofiledialogfolderpicker) dialog.allowmultiselect = false if dialog.show = -1 path = dialog.selecteditems(1) ' begin loop. = 3 tabcount 'set = number of first sheet want pdf in order left right tabcount if sheets(i).visible <> xlsheetvisible else redim preserve asheetnames(i-2) 'subtract 2, since starts @ 3 asheetnames(i-2) = sheets(i).name 'build array of sheets print end if next fname = 'make here bulk file name sheets(asheetnames).exportasfixedformat type:=xltypepdf, filename:=path & "\" & fname, quality:=xlqualitystandard, _ includedocproperties:=true, ignoreprintareas:=false, openafterpublish:=true end if end sub
note: no guarantees expressed or implied, may have debugging, off top of head, might work...
Comments
Post a Comment