In your current routine, you are creating a Monarch object, using it and then destroying it. In more general terms, you could create a separate routine to create a locally scoped Monarch object (thus opening it only once) and then create a routine that would use this object to open your files and models, whether it's a singe file/model or multiple. Once the files are processed, you would then close and destroy the Monarch object. This is more efficient as you only need to create the object once for all processes and close it when no longer needed, rather than opening/closing with each process.
Hope that makes sense.
Thanks for your advice. I believe I mostly understood. I was having trouble with the locally scoped object. I ended up using my same function but made the MonarchObj Static instead of Dim. I then set it to Nothing at the end of my loop counter and it seems to work pretty well. I thought I would post my final code in case it might help somebody else.
On Error GoTo Err_OpenMon
Static MonarchObj As Object
Dim OpenFile, openmod, t As Boolean
Set MonarchObj = GetObject("", "Monarch32")
If MonarchObj Is Nothing Then
Set MonarchObj = CreateObject("Monarch32")
MonarchObj.Visible = True
t = MonarchObj.SetLogFile(CurrentProject.path & "\Log\Monarch.log", False)
OpenFile = MonarchObj.SetReportFile(strFile, False)
If OpenFile = True Then
openmod = MonarchObj.SetModelFile(strMod)
If openmod = True Then
If blType = True Then
MonarchObj.JetExportTable strFileResult, strTable, 0
MonarchObj.Visible = False
If lngCount = 1 Or IsEmpty(lngCount) Then
Set MonarchObj = Nothing
MsgBox Err.Number & " - " & Err.Description & vbCrLf & vbCrLf & "Error occurred during OpenMon function.", vbCritical, "Error!"