5 Replies Latest reply: May 15, 2014 10:07 AM by Data Kruncher RSS

    model file fails to open

      The lesson14.xmod fails to open when executing the code listed below.  Therefore, data exports never happen.


      Monarch 10.0 w/ std install

      Verified files exists in the default directories

      Running Windows Ultimate, Excel 2003.

      Launching code as a VB Module from Excel


      Any ideas?




      Begin Code:


      Attribute VB_Name = "MonarchSample"


      Private Sub Form_Load()


      Dim MonarchObj As Object


      Dim openfile, openmod, t As Boolean


      'If Monarch is currently active GetObject will use Monarch. If it is not use the CreateO

      'open another copy of Monarch.


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


      If MonarchObj Is Nothing Then


      Set MonarchObj = CreateObject("Monarch32")


      End If


      t = MonarchObj.SetLogFile("C:\MonTemp\MPrg_G5.log", False)


      openfile = MonarchObj.SetReportFile("Classic.prn", False)


      If openfile = True Then


      openmod = MonarchObj.SetModelFile("Lesson14.xmod")


      If openmod = True Then


      'Set filter for each frame and export to Excel


      MonarchObj.CurrentFilter = "Fandangos records"


      MonarchObj.ExportTable ("Fandangos.xls")


      MonarchObj.CurrentFilter = "No Returns"


      MonarchObj.ExportTable ("No Returns.xls")


      End If



      End If






      End Sub


      Sub number1()


      End Sub

        • model file fails to open
          Data Kruncher

          Hi chipshot and welcome to the forum.


          A couple of points based on your code. First, put the code in a module instead of the code for a form.


          Next, step using the F8 key through the code to determine what's working and what isn't. Then you should see Monarch start up, the report displayed in Monarch, the model being applied, and the export taking place.


          At first glance, I'd say that you need to supply complete file paths instead of just the file name, so that Monarch can locate the intended files and export your files to where you want them to go. The rest of the code looks to be functional enough as a test to get your feet wet with controlling Monarch via VBA.