Populate multi tab workbook along with populating pdf file

I have an Excel macro that process data and generates individual reports for distribution.  The "printing" options are to physically print the individual report as they are created, or populate the reports into a pdf file for mass printing.  (Sample code attached).

What I would like to be able to do (at the time of creating the pdf prior to clearing the excel template for the next individual report) is to simultaneously copy the report into a "master" excel file with the same new file and naming convention of the pdf file.  Or, save the interim file created in excel for pdf creation, prior to publishing the pdf.  Is this doable?  If so how/where would I include in the sample code?
Public-DestPrtWbk-As-Workbook.docx
uadAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
It isn't clear why you show as the code as text on a Word document. I haven't yet looked at in detail, but here it is:
Public DestPrtWbk As Workbook
Public Idx

Sub LoadData
Load Data in Array – Data_Array(x,y,z)
End sub

Sub CreateReports_pdf() 
'Sets the "pdf" print document and call individual reports generation

    Dim x&
    Dim z As Integer
    Dim mResult
    Set DestPrtWbk = Workbooks.Add
    ThisWorkbook.Activate

    Workbooks.Open Filename:=fPath & "Rpt_Master.xlsm"
    Sheets("report").Select
    For x = 1 To UBound(Data_Array())
        
           mResult = x Mod 2300 
        If mResult = 0 Then
            z = z + 1

            DestPrtWbk.ExportAsFixedFormat Type:=xlTypePDF, _
                Filename:=fPath & "Reports" & CStr(z) & ".pdf", Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, _
                OpenAfterPublish:=False
                
            DestPrtWbk.Activate
            For Idx = DestPrtWbk.Sheets.Count - 1 To 1 Step -1
                Application.DisplayAlerts = False
                DestPrtWbk.Sheets(Idx).Delete
                Application.DisplayAlerts = False
            Next Idx '

            Application.Wait (Now + TimeValue("0:00:30"))
            Windows("Rpt_Master.xlsm").Activate
            Sheets("report").Select

Call Reports (x)
       
 End If

Sub Reports(x)
'Populates the each "individual" Report in the excel template and call ReportOutput
    Dim a&
    Dim y&
        Range("a5").Select
        ActiveCell.Value = Data_Array(x, 3, 1) & " - " & Data_Array(x, 2, 1)
        ActiveCell.Offset(1, 2).Value = Data_Array(x, 4, 1)
        ActiveCell.Offset(2, 2).Value = Round(Data_Array(x, 6, 1))
Etc. . . . 
'print
        Call RptOutput (x) 

End Sub


Sub RptOutput (x)

    Select Case Prnt
        Case 1 'output to printer
            ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
                IgnorePrintAreas:=False

        Case 2 'output to pdf
        
           'print pdf
            Sheets("report").Copy After:=DestPrtWbk.Sheets(DestPrtWbk.Sheets.Count)

            DestPrtWbk.Activate
                If x = 1 Then 'delete unnecessary sheets
                    For Idx = DestPrtWbk.Sheets.Count - 1 To 1 Step -1
                        Application.DisplayAlerts = False
                        DestPrtWbk.Sheets(Idx).Delete
                        Application.DisplayAlerts = False
                    Next Idx
            	 End If
                
    End Select
    
    'clear master form

End Sub

Open in new window

uadAuthor Commented:
The code was copied into Word since it's a extract of the relevant part of the complete macro that would need to be addressed.  I could have just as easily pasted into excel if it makes any difference.
uadAuthor Commented:
got it.

Code snippet:

Public DestPrtWbk As Workbook
Public Idx

Sub LoadData
Load Data in Array – Data_Array(x,y,z)
End sub

Sub CreateReports_pdf()
'Sets the "pdf" print document and call individual reports generation

    Dim x&
    Dim z As Integer
    Dim mResult
    Set DestPrtWbk = Workbooks.Add
    ThisWorkbook.Activate

    Workbooks.Open Filename:=fPath & "Rpt_Master.xlsm"
    Sheets("report").Select
    For x = 1 To UBound(Data_Array())
       
           mResult = x Mod 2300
        If mResult = 0 Then
            z = z + 1

            DestPrtWbk.ExportAsFixedFormat Type:=xlTypePDF, _
                Filename:=fPath & "Reports" & CStr(z) & ".pdf", Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, _
                OpenAfterPublish:=False
               
            DestPrtWbk.Activate
            For Idx = DestPrtWbk.Sheets.Count - 1 To 1 Step -1
                Application.DisplayAlerts = False
                DestPrtWbk.Sheets(Idx).Delete
                Application.DisplayAlerts = False
            Next Idx '

            Application.Wait (Now + TimeValue("0:00:30"))
            Windows("Rpt_Master.xlsm").Activate
            Sheets("report").Select

Call Reports (x)
       
 End If

Sub Reports(x)
'Populates the each "individual" Report in the excel template and call ReportOutput
    Dim a&
    Dim y&
        Range("a5").Select
        ActiveCell.Value = Data_Array(x, 3, 1) & " - " & Data_Array(x, 2, 1)
        ActiveCell.Offset(1, 2).Value = Data_Array(x, 4, 1)
        ActiveCell.Offset(2, 2).Value = Round(Data_Array(x, 6, 1))
Etc. . . .
'print
        Call RptOutput (x)

End Sub


Sub RptOutput (x)

    Select Case Prnt
        Case 1 'output to printer
            ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
                IgnorePrintAreas:=False

        Case 2 'output to pdf
       
           'print pdf
            Sheets("report").Copy After:=DestPrtWbk.Sheets(DestPrtWbk.Sheets.Count)

            DestPrtWbk.Activate
                If x = 1 Then 'delete unnecessary sheets
                    For Idx = DestPrtWbk.Sheets.Count - 1 To 1 Step -1
                        Application.DisplayAlerts = False
                        DestPrtWbk.Sheets(Idx).Delete
                        Application.DisplayAlerts = False
                    Next Idx
                   End If
               
    End Select
   
    'clear master form

End Sub
GrahamSkanRetiredCommented:
As to the question, why not put a 'Save As' just before or just after the export statement?
'...
            z = z + 1

            DestPrtWbk.ExportAsFixedFormat Type:=xlTypePDF, _
                Filename:=fPath & "Reports" & CStr(z) & ".pdf", Quality:=xlQualityStandard, _
                IncludeDocProperties:=True, IgnorePrintAreas:=False, _
                OpenAfterPublish:=False
            DestPrtWbk.SaveAs fPath & "Reports" & CStr(z) & ".xlsx", xlOpenXMLWorkbook
            DestPrtWbk.Activate
            For Idx = DestPrtWbk.Sheets.Count - 1 To 1 Step -1
                Application.DisplayAlerts = False
'...

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
uadAuthor Commented:
Sometimes it is the most obvious that is missed.

Thank you - it works
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.