1 Reply Latest reply: May 15, 2014 10:01 AM by Nick Osdale-Popa RSS

    Exporting Multiple Summaries using VB Code

    Matixsnow _

      I have multiple summaries in a Monarch Model.  Is there anyway to export multiple summaries in monarch from one model?

       

      Here is the code I use to export the first summary in the model.

       

      ExecuteMonarch:

          openfile = MonarchObj.SetReportFile(varReportFileName, False)

          'varTempExportMonarch = "C:\data\tempMonarch.csv"

          'If Dir(varTempExportMonarch) <> "" Then Kill varTempExportMonarch

          If openfile = True Then

             openmod = MonarchObj.SetModelFile(varModelFileName)

             If openmod = True Then

                procReturn = MonarchObj.JetExportSummary(varExportFileName, varExportTable, 2)

        • Exporting Multiple Summaries using VB Code
          Nick Osdale-Popa

          Here's is just a snippet from my Monarch Class Library.

           

          Basically, you want to get the summary count, then loop through the summaries, set it as the current summary and then export each one.

           

                  SummaryCount = .SummaryCount

                  If SummaryCount = 0 Then

                      blSuccess = False

                      sProblem = "No Summaries found in: " & sModelFile

                      Err.Raise vbObject + NoSummaries, "Monarch", sProblem

                  End If

                   

                  Set mstrsFiles = New Collection

                  For SummaryIdx = 0 To SummaryCount - 1

                      SummaryName = UCase(.GetSummaryNameAt(SummaryIdx))

                      .CurrentSummary SummaryName

                      blSuccess = .JetExportSummary(sExportFile, SummaryName, iAppendFlag)

                      If blSuccess = False Then

                          sProblem = "Error Exporting Summary: " & SummaryName

                          Err.Raise vbObject + SummaryErr, "Monarch", sProblem

                      End If

                      mstrsFiles.Add Key:=SummaryName, Item:=msSummary

                  Next SummaryIdx

          /code