1 Reply Latest reply: May 15, 2014 9:53 AM by Data Kruncher RSS

    Multiple Tables Export Automatically

    MorseB _

      How do I need to write code to export two reports to one Excel file? 


          Dim monarchobj As Object

          Dim openfile As Boolean

          Dim openmod As Boolean

          Dim t As Boolean

          Dim expfile As Boolean

          Dim stringTableName As String

          Dim stDocName As String

          Dim strname As String

          Dim stappname As String




          '05-16-2007 added deletion of ChemDlyStmt_excl.xls file

          Kill (str_server_CashRec & "ImportDataDownloadChemicalChemDlyStmt_excl.xls")


          MsgBox "Monarch will now start to create Excel file - ChemDlyStmt_excl.xls.  Monarch may require a user id to open the application."


          'If Monarch is currently active GetObject() will use Monarch. If it is not currently active CreateObject()will open Monarch


           Set monarchobj = GetObject("", "Monarch32")

           If monarchobj Is Nothing Then

           Set monarchobj = CreateObject("Monarch32")

           End If


           t = monarchobj.setlogfile("C:MonTempMPrg_G5.log", False)


           openfile = monarchobj.SetReportFile(str_server_CashRec & "ImportDataDownloadChemical204_statement.pdf", False)

           openfile = monarchobj.SetReportFile(str_server_CashRec & "ImportDataDownloadChemical10013_statement.pdf", False)


          'open Monarch module

           If openfile = True Then

              openmod = monarchobj.SetModelFile(str_server_CashRec & "ReconWinMonarchX-ModsChemicalDailyActWeb.xmod")


              monarchobj.SetView ("T")


              'set Monarch filter

              If openmod = True Then

              monarchobj.CurrentFilter = "Amt"


              stringTableName = "ChemDlyStmt_excl"


              'overwrite table

              expfile = monarchobj.JetExportTable(str_server_CashRec & "ImportDataDownloadChemicalChemDlyStmt_excl.xls", stringTableName, 0)


              End If


           End If




        • Multiple Tables Export Automatically
          Data Kruncher

          Hi Beth,


          You're so close...   smile.gif[/img] 




          [font="courier"]openfile = monarchobj.SetReportFile(str_server_CashRec & "ImportDataDownloadChemical10013_statement.pdf", False)



          [font="courier"]openfile = monarchobj.SetReportFile(str_server_CashRec & "ImportDataDownloadChemical10013_statement.pdf", True)

            /font[/quote]The last parameter for SetReportFile determines whether Monarch will add the specified report to those already open, or replace the report(s) which is/are already open with the specified report.


          So what your code is doing now is opening 204_statement.pdf, then effectively closing it and opening 10013_statement.pdf.