I am trying to create a filename dynamically by counting each time a particular sub is called. The sub creates a pdf file and since at this point, don't know how to programmatically combine all the pdfs created, I am using a numerical system so that when the reports are finished printing, I can manually combine all open pdf files into one file. Since the code was created by someone else, I don't want to alter it too much. The Excel macro runs a series of reports. Each report is run individually (a separate macro) and some of the reports have multiple print ranges.
Current "Top Level" Macro:
This line of code appears in all the macros:
I had started to do something like this in the "top level" macro:
and then comment out the printout code within the individual macro, however, since the individual macro may have more than one printout statement, this idea didn't seem like it would work as expected. Also, the other reason for dynamically creating the xxx1.pdf, xxx2.pdf, xxx3.pdf is then I wouldn't need to worry about changing the numbers if new reports are added.
Current "Top Level" Macro:
Code:
Sub PrtAllRep()
Application.Run Macro:="07F_FILE.XLS!PrtCover"
Application.Run Macro:="07F_FILE.XLS!PrtOvrvw"
Application.Run Macro:="07F_FILE.XLS!PrtSumReport"
..
..
This line of code appears in all the macros:
Code:
..
..
ActiveWindow.SelectedSheets.PrintOut Copies:=1
..
..
I had started to do something like this in the "top level" macro:
Code:
Application.Run Macro:="07F_FILE.XLS!PrtCover"
RunReportAsPDF prmRptName:="COVER PAGE", prmPdfName:=Replace(stpath, ".XLS", "1.PDF")
Application.Run Macro:="07F_FILE.XLS!PrtOvrvw"
RunReportAsPDF prmRptName:="OVERVIEW", prmPdfName:=Replace(stpath, ".XLS", "2.PDF")
and then comment out the printout code within the individual macro, however, since the individual macro may have more than one printout statement, this idea didn't seem like it would work as expected. Also, the other reason for dynamically creating the xxx1.pdf, xxx2.pdf, xxx3.pdf is then I wouldn't need to worry about changing the numbers if new reports are added.