0 Replies Latest reply: Jun 15, 2010 1:16 PM by thehacker010 _ RSS

    Open Monarch Pro with Excel Macro?

    thehacker010 _

      I was asked a day ago about this error message that someone got in Excel when they tried to start Monarch Profrom a macro.  His macro can open programs like calculator or MS paint, but when it tries to open Monarch, he gets this error:

       

      "Cannot open file MFWFIL32.DLL.  File is missing or version is incorrect."

       

      Monarch Pro runs just fine when you run it from the normal executable.  Is there a way to create a macro in Excel that will open Monarch Pro?

       

      P.S. I don't remember what the exact code was for his macro, but I tried this and it did not work.  Keep in mind this macro below works fine for stuff like calculator or paint.

       

      Sub ExecMonarch()

      AppVal = Shell("C:\.....\Monarch.exe",1)

      End Sub[/code]

        • Open Monarch Pro with Excel Macro?
          Data Kruncher

          Yes, you can start Monarch with a VBA macro, but you must use it as an object. As you've discovered, don't try to start it with Shell.

           

          Visit [URL is no longer valid] for a full description of the process and links to a Programmer's Guide as well as other tools and resources relating to automating Monarch.

            • Open Monarch Pro with Excel Macro?
              thehacker010 _

              Well, I tried this code but I got two errors.  It says compiler error on the "while" and run time error 429  “ActiveX component can’t create object" on the Monarch_Launch.  Any ideas?

               

              Sub Main()

              Monarch_Launch.

              Do While IsServerActive()

              DoEvents

              While

              End Sub

               

              Sub Monarch_Launch ()

              Dim ServerOn as Integer

              ServerOn=IsServerActive()

              If ServerOn=0 then

              Set MonarchObj = CreateObject(“Monarch32”)

              End If

              End Sub

               

              Function IsServerActive()

              On Error Goto NoServer

              If MonarchObj.IsActive > 0 then

              IsServerActive = 1

              End If

              Exit Function

              NoServer:

              IsServerActive = 0

              Exit Function

              End Function

              /code

                • Open Monarch Pro with Excel Macro?
                  thompssc _

                  Do While IsServerActive()

                  DoEvents

                  While

                  /code

                   

                  I'm no VBA guru, but shouldn't that be

                   

                  Do While IsServerActive()

                  DoEvents

                  Loop

                  /code

                  • Open Monarch Pro with Excel Macro?
                    Data Kruncher

                    There are a few reasons for the problems that you've encountered.

                     

                    First and foremost is that code sample supplied in the programmer's guide won't work as presented as there are bugs, as you've seen. I see that Scott has already commented on that.

                     

                    Next is that you must declare the Monarch object in the General section of the code, as outlined on page 29 of the PDF. Don't forget to set the reference to the Monarch object (Tools -> References...) as well.

                     

                    That said, this works (while basic in its functionality and presentation):

                     

                    Dim MonarchObj As Object

                     

                    Sub Main()

                    Monarch_Launch

                    Do While IsServerActive()

                    DoEvents

                    Loop

                    End Sub

                     

                    Sub Monarch_Launch()

                     

                    Dim ServerOn As Integer

                    ServerOn = IsServerActive()

                    If ServerOn = 0 Then

                     

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

                    If MonarchObj Is Nothing Then

                    Set MonarchObj = CreateObject(“Monarch32”)

                    End If

                    End If

                    End Sub

                     

                    Function IsServerActive()

                    On Error GoTo NoServer

                    If MonarchObj.IsActive > 0 Then

                    IsServerActive = 1

                    End If

                    Exit Function

                    NoServer:

                    IsServerActive = 0

                    Exit Function

                    End Function[/code]