How to pass a runtimeparameter to a Model using COM

Al_22614
Al_22614 Altair Community Member
edited October 2020 in Community Q&A

Hello All:

I am trying to pass a runtimeparameter value to a calculated field that is used in a Filter in a Model using COM (using VBA).  I have done this before, but it has been a while.  I am drawing a blank.   I am tr

Sub TestRunTimeVariable
Dim ARASUMM2 As String
Dim EDIFILE As String
Dim SummaryFile2 As String
ThisYrMon = "202009"
'
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'
Set FSO = CreateObject("Scripting.FileSystemObject")
'
SetRuntimeParameter = ThisYrMon
'
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Const SumFolder2 = "V:\EDI\EDI_Master_Folder\2020\09_September\"
Const ProjFolder = "C:\Users\user2\ThorTestFolder\Projects\"
SummaryFile2 = "09_September_EDI_Detail_Report - Bkup.xlsx"
'
ARASUMM2 = "MasterEDIExport"
'
ProjName = "PITCO_EDI_MODEl_Update.dprj"
'
Set MonarchObj = GetObject("", "Monarch32")

If MonarchObj Is Nothing Then
Set MonarchObj = CreateObject("Monarch32")
'
End If
'
OpenFile = MonarchObj.SetProjectFile(ProjFolder & ProjName)
'Stop
If OpenFile = True Then
MonarchObj.CurrentSummary = ARASUMM2
EXPFILE = MonarchObj.JETEXPORTSUMMARY(SumFolder2 & SummaryFile2, ARASUMM2, 2)
'
Else
MsgBox "This Menu Selection Failed... Please Make Correction"
GoTo UFinn
End If
'
MonarchObj.CloseAllDocuments
MonarchObj.Exit
Set MonarchObj = Nothing
'
UFinn:
'
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub


When Launching Monarch Project/Model, I am expecting Monarch to ingest the Value "202009" for the Runtime Variable ThisYrMon, but it is not working.  I am not getting the filtered results I expect.   The filter is defaulted in the Summary, so I did not think I needed set CurrentFilter.   When I run the Project/Model manually everythis works as expected.

Thanks in advance for any help.


------------------------------
Al Rice
------------------------------

Tagged:

Best Answer

  • Al_22614
    Al_22614 Altair Community Member
    edited October 2020 Answer ✓
    Hello All:

    I figured it out...

    If OpenFile = True Then
    ThisMon = MonarchObj.SetRuntimeParameter("ThisYrMon", ThisYr)

    ThisMon is Boolean variable

    Searching the Discussion archives yielded clues to my problem...

    Thanks All

    ------------------------------
    Al Rice
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 10-19-2020 10:28 AM
    From: Al Rice
    Subject: How to pass a runtimeparameter to a Model using COM

    Hello All:

    I am trying to pass a runtimeparameter value to a calculated field that is used in a Filter in a Model using COM (using VBA).  I have done this before, but it has been a while.  I am drawing a blank.   I am tr

    Sub TestRunTimeVariable
    Dim ARASUMM2 As String
    Dim EDIFILE As String
    Dim SummaryFile2 As String
    ThisYrMon = "202009"
    '
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    '
    Set FSO = CreateObject("Scripting.FileSystemObject")
    '
    SetRuntimeParameter = ThisYrMon
    '
    '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Const SumFolder2 = "V:\EDI\EDI_Master_Folder\2020\09_September\"
    Const ProjFolder = "C:\Users\user2\ThorTestFolder\Projects\"
    SummaryFile2 = "09_September_EDI_Detail_Report - Bkup.xlsx"
    '
    ARASUMM2 = "MasterEDIExport"
    '
    ProjName = "PITCO_EDI_MODEl_Update.dprj"
    '
    Set MonarchObj = GetObject("", "Monarch32")

    If MonarchObj Is Nothing Then
    Set MonarchObj = CreateObject("Monarch32")
    '
    End If
    '
    OpenFile = MonarchObj.SetProjectFile(ProjFolder & ProjName)
    'Stop
    If OpenFile = True Then
    MonarchObj.CurrentSummary = ARASUMM2
    EXPFILE = MonarchObj.JETEXPORTSUMMARY(SumFolder2 & SummaryFile2, ARASUMM2, 2)
    '
    Else
    MsgBox "This Menu Selection Failed... Please Make Correction"
    GoTo UFinn
    End If
    '
    MonarchObj.CloseAllDocuments
    MonarchObj.Exit
    Set MonarchObj = Nothing
    '
    UFinn:
    '
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    End Sub


    When Launching Monarch Project/Model, I am expecting Monarch to ingest the Value "202009" for the Runtime Variable ThisYrMon, but it is not working.  I am not getting the filtered results I expect.   The filter is defaulted in the Summary, so I did not think I needed set CurrentFilter.   When I run the Project/Model manually everythis works as expected.

    Thanks in advance for any help.


    ------------------------------
    Al Rice
    ------------------------------

Answers

  • Al_22614
    Al_22614 Altair Community Member
    edited October 2020 Answer ✓
    Hello All:

    I figured it out...

    If OpenFile = True Then
    ThisMon = MonarchObj.SetRuntimeParameter("ThisYrMon", ThisYr)

    ThisMon is Boolean variable

    Searching the Discussion archives yielded clues to my problem...

    Thanks All

    ------------------------------
    Al Rice
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 10-19-2020 10:28 AM
    From: Al Rice
    Subject: How to pass a runtimeparameter to a Model using COM

    Hello All:

    I am trying to pass a runtimeparameter value to a calculated field that is used in a Filter in a Model using COM (using VBA).  I have done this before, but it has been a while.  I am drawing a blank.   I am tr

    Sub TestRunTimeVariable
    Dim ARASUMM2 As String
    Dim EDIFILE As String
    Dim SummaryFile2 As String
    ThisYrMon = "202009"
    '
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    '
    Set FSO = CreateObject("Scripting.FileSystemObject")
    '
    SetRuntimeParameter = ThisYrMon
    '
    '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Const SumFolder2 = "V:\EDI\EDI_Master_Folder\2020\09_September\"
    Const ProjFolder = "C:\Users\user2\ThorTestFolder\Projects\"
    SummaryFile2 = "09_September_EDI_Detail_Report - Bkup.xlsx"
    '
    ARASUMM2 = "MasterEDIExport"
    '
    ProjName = "PITCO_EDI_MODEl_Update.dprj"
    '
    Set MonarchObj = GetObject("", "Monarch32")

    If MonarchObj Is Nothing Then
    Set MonarchObj = CreateObject("Monarch32")
    '
    End If
    '
    OpenFile = MonarchObj.SetProjectFile(ProjFolder & ProjName)
    'Stop
    If OpenFile = True Then
    MonarchObj.CurrentSummary = ARASUMM2
    EXPFILE = MonarchObj.JETEXPORTSUMMARY(SumFolder2 & SummaryFile2, ARASUMM2, 2)
    '
    Else
    MsgBox "This Menu Selection Failed... Please Make Correction"
    GoTo UFinn
    End If
    '
    MonarchObj.CloseAllDocuments
    MonarchObj.Exit
    Set MonarchObj = Nothing
    '
    UFinn:
    '
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    End Sub


    When Launching Monarch Project/Model, I am expecting Monarch to ingest the Value "202009" for the Runtime Variable ThisYrMon, but it is not working.  I am not getting the filtered results I expect.   The filter is defaulted in the Summary, so I did not think I needed set CurrentFilter.   When I run the Project/Model manually everythis works as expected.

    Thanks in advance for any help.


    ------------------------------
    Al Rice
    ------------------------------