🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to Excel VBA macro to run through many text files and export outputs?

User: "Madison Marrocco"
New Altair Community Member
Updated by Madison Marrocco

In monarch 10.5  we had a reference tlb file to hook.  We no longer use this version and have 17.1 now,  but when we went to look for this file in the monarch folders we didn’t find it.  Is this still how

Without it, it doesn’t recognize the new version when trying to set the object.  Does this still function this way or has it changed as to how to create Monarch as an object to run? 

image

Find more posts tagged with

Sort by:
1 - 1 of 11
    User: "Mo Abdolrahim"
    Altair Employee
    Updated by Mo Abdolrahim

    Hi Madison,

    In the newer version of Monarch (v2020+), there is no need to add a reference to Monarch.exe as long as Monarch is installed on a PC.  If you installed Monarch 64-bit, then you should use Excel 64-bit for using Monarch COM.

    The following VBA script worked fine in Excel 64-bit:

    Sub test()
    Dim monarchobj As Object
    Dim Monver As Variant
    Dim openfile, openmod As Boolean
    Const reportfolder = "C:\mo\DW\desktop\Monarch Altair\com_test\reports\"
    Const modelfolder = "C:\mo\DW\desktop\Monarch Altair\com_test\models\"
    Const exportfolder = "C:\mo\DW\desktop\Monarch Altair\com_test\exports\"

    Set monarchobj = CreateObject("monarch32")
    If monarchobj Is Nothing Then
     Set monarchobj = CreateObject("Monarch32")
    End If

    Monver = monarchobj.Version
    MsgBox (Monver)
    openfile = monarchobj.SetReportFile(reportfolder & "classic.prn", False)
    openmod = monarchobj.SetModelFile(modelfolder & "Lesson9.dmod")
    If openfile = True And openmod = True Then
      monarchobj.CurrentFilter = "Fandangos Records"
      monarchobj.ExportTable (exportfolder & "Fandangos.xls")
      monarchobj.CurrentFilter = "No Returns"
      monarchobj.ExportTable (exportfolder & "No_Returns.xls")
    Else
      MsgBox ("errro")
    End If
    monarchobj.CloseAllDocuments
    monarchobj.Exit
    Set monarch = Nothing
    End Sub

    image

    image

    Regards

     Mo