16 Replies Latest reply: Apr 9, 2015 12:38 PM by Gareth Horton RSS

    VB and Monarch

    xboxremote _

      I recently discovered the Monarch Programmer's Guide (located at [URL="http://www.datawatch.com/_support/downloads_updates.php#MonarchGuides"]http://www.datawatch.com/_support/downloads_updates.php#MonarchGuides[/URL]) and was just wondering why I haven't seen people really talking about this? It was very surprising to me that Monarch is set up to work with languages that support COM/OLE/Active X like VB or VBA (for Microsoft Access or Excel Macros), and many other languages, and that it's so easy, and yet I hadn't heard about it anywhere besides just stumbling across it!

       

      So basically, there is a very wide array of properties and methods that you can call within an Excel Macro, or Access Database, or other types of apps, where you can have it open up a set of reports, apply a model, export a table or summary, and do plenty of other things, and do all of this automatically. I've seen plenty of threads with people talking about writing batch files for this same purpose, which, as far as I know, contain a lot less functionality because you can't actually access the same methods that you can doing it through an actual application that you've developed.

       

      So, why hasn't this been talked about much? Why are people writing batch files for this same purpose? Is this too good to be true? Just curious what other peoples' opinions are, especially those who have worked with these properties/methods, and what they have accomplished with them, and any downsides they encountered. Thanks all!

        • VB and Monarch
          Nick Osdale-Popa

          Well, good question... and it stems from the fact that you are probably dealing with a lot of end users who are not programmers, but more along the lines of clerks and or CPAs.

           

          I'm a programmer and use the COM object extensively for my endusers who don't have the time to learn Monarch. I hide its functionality exclusively from them. This required a lot of code.

           

          For those who do wish to delve into the programming of Monarch, Sandy (Data Kruncher) provides a tool that goes in depth of each method and property. You can find the tool at www.********************[/url].

            • VB and Monarch
              Data Kruncher

              I was just thinking back to the first time that Nick showed me some of his custom applications in the presentation room at the hotel, after I'd just presented my approach for automating Monarch to produce custom Excel reports. It was amazing work, and I know that he continues to produce outstanding tools for his team.

               

              As for my programming tool, you'll find [URL="http://********************/tips/monarch-programming-class"]the specific details[/URL] should describe what you'll likely be interested in knowing.

               

              Thanks for the mention Nick.

                • VB and Monarch
                  xboxremote _

                  Thank you both for the replies! I'm glad to know I'm not the only one curious about Monarch's API, and it sounds like you two have plenty of experience with it. I'm familiar with Data Kruncher's blog, and I have read quite a bit from it. It's come very much in handy so far!

                   

                  I would call myself an intermediate programmer, and I only have experience creating business applications. Since my company uses Monarch as the basis for almost everything we do, I'm so curious and excited to see what I can develop for them.

                   

                  Being so new to these forums, I guess I don't know what kinds of backgrounds or what kinds of positions of people I'm seeing here. But you're right, it's probably mostly people unfamiliar with programming of any kind. I guess the big surprise for me was that so many people were curious about creating batch files, when it seems easier (to me, anyway) to just write up a little code in a macro to do the job. But then again, I have formal education and a fair amount of experience in this...

                   

                  If only everyone here knew the potential though

                   

                  Thanks again for the replies!

                    • VB and Monarch
                      Data Kruncher

                      Glad to hear you're enjoying the site!

                       

                      As you said that your company uses Monarch extensively, I'm sure that your story as you progress with your automation project(s) would be of interest to the readers of the site. Send me a Private Message when you have a moment if you'd care to share some details.

                       

                      Yes, for those with the experience and ability, it's not difficult or time consuming to write a little program that will do what you need, but the great thing that we users can take advantage of is the flexibility that Monarch offers: write code if you can, [URL="http://********************/tips/monarch-batch-file-generator"]create a batch file[/URL] if that's all you need, or just do it yourself with a few more clicks.

                       

                      Regardless of your approach, Monarch can and should be your go-to tool for desktop BI needs.

                        • VB and Monarch
                          Nick Osdale-Popa

                          And there are some advantages of batch files over code. One of the features of the command line is that you have a switch that will export all summaries, something that isn't readily available in code without doing a loop.

                            • VB and Monarch
                              xboxremote _

                              Good point about the batch file's ability to export all summaries at once. We don't typically export multiple summaries at once, but when we need to, I'd imagine I would just use a loop. If it's automated, then it shouldn't take much longer to export both that way (assuming it takes the same amount of processing time to export "all" versus the aggregate amount of time it takes exporting each one individually).

                               

                              Data Kruncher, I will definitely keep you updated as I go through this. Thank you both for the replies!

                                • VB and Monarch
                                  Bill Watson

                                  Most of the Monarch stuff we build is intended to go onto our Datapump machine, so we build both the model and the project which contains the export details.

                                   

                                  I still sometimes run thing via vbscripts though, especially if it is a process another team might want to run manually on an adhoc basis. Because of the functionality in the API, you can runallexports() which is what we tend to do.

                                   

                                  In  vbscript I use the following code mostly:

                                   

                                  Dim ObjMon

                                  dim blopenprj

                                  dim blrun

                                  dim objlog

                                  Dim strRoot

                                  Dim strProject

                                   

                                  strroot = "C:\DATA\TEST\" 'change this to the path that contains your projects

                                   

                                  set objmon = getobject("","Monarch32")

                                  if objmon is nothing then

                                       Set MonarchObj = CreateObject("Monarch32")

                                  End If

                                   

                                  rem *** Log File ***

                                  objlog = objmon.SetLogFile(strRoot & "\monarch.log", False)

                                   

                                  strProject = "MYPROJECTNAME" 'change this to the project being run (dont put in the xprj - its added below)

                                  if strProject <> "" then

                                     rem *** open project file ***

                                     blopenprj = Objmon.Setprojectfile(strRoot & strProject & ".XPRJ" )

                                   

                                     rem *** run exports if file open

                                     If blopenprj = True Then

                                        blrun = objmon.runallexports()

                                        rem *** notify user and stop if problem running exports ***          

                                        if blrun = false then

                                           msgbox "Project Named " & strproject & ".XPRJ failed. Please check monarch.log and rerun entire process."

                                           Objmon.CloseAllDocuments

                                           Objmon.Exit

                                           wscript.quit

                                        end if

                                     rem *** notify user and stop if problem opening project ***

                                     else

                                        msgbox "Project Named " & strproject & ".XPRJ not valid. Please check monarch.log and rerun entire process."

                                        Objmon.CloseAllDocuments

                                        Objmon.Exit

                                        wscript.quit

                                     End If

                                   

                                     rem *** close monarch bits ***

                                     Objmon.CloseAllDocuments

                                   

                                  end if

                                   

                                  objmon.exit

                                  wscript.quit

                                  /code

                                   

                                  That is my basic automation of monarch via VBscript. just save the above into a .vbs file and it should run fine on any pc with monarch pro (8 or above) installed.

                                    • VB and Monarch
                                      xboxremote _

                                      Most of the Monarch stuff we build is intended to go onto our Datapump machine, so we build both the model and the project which contains the export details.

                                       

                                      I still sometimes run thing via vbscripts though, especially if it is a process another team might want to run manually on an adhoc basis. Because of the functionality in the API, you can runallexports() which is what we tend to do.

                                       

                                      In  vbscript I use the following code mostly:

                                       

                                      Dim ObjMon

                                      dim blopenprj

                                      dim blrun

                                      dim objlog

                                      Dim strRoot

                                      Dim strProject

                                       

                                      strroot = "C:\DATA\TEST\" 'change this to the path that contains your projects

                                       

                                      set objmon = getobject("","Monarch32")

                                      if objmon is nothing then

                                           Set MonarchObj = CreateObject("Monarch32")

                                      End If

                                       

                                      rem *** Log File ***

                                      objlog = objmon.SetLogFile(strRoot & "\monarch.log", False)

                                       

                                      strProject = "MYPROJECTNAME" 'change this to the project being run (dont put in the xprj - its added below)

                                      if strProject <> "" then

                                         rem *** open project file ***

                                         blopenprj = Objmon.Setprojectfile(strRoot & strProject & ".XPRJ" )

                                       

                                         rem *** run exports if file open

                                         If blopenprj = True Then

                                            blrun = objmon.runallexports()

                                            rem *** notify user and stop if problem running exports ***          

                                            if blrun = false then

                                               msgbox "Project Named " & strproject & ".XPRJ failed. Please check monarch.log and rerun entire process."

                                               Objmon.CloseAllDocuments

                                               Objmon.Exit

                                               wscript.quit

                                            end if

                                         rem *** notify user and stop if problem opening project ***

                                         else

                                            msgbox "Project Named " & strproject & ".XPRJ not valid. Please check monarch.log and rerun entire process."

                                            Objmon.CloseAllDocuments

                                            Objmon.Exit

                                            wscript.quit

                                         End If

                                       

                                         rem *** close monarch bits ***

                                         Objmon.CloseAllDocuments

                                       

                                      end if

                                       

                                      objmon.exit

                                      wscript.quit

                                      /code

                                       

                                      That is my basic automation of monarch via VBscript. just save the above into a .vbs file and it should run fine on any pc with monarch pro (8 or above) installed.[/QUOTE]

                                       

                                      Awesome, thank you for the sample! That's pretty nifty. I'll have to play around with that one some. I'm excited to see what I can come up with...

                                        • Re: VB and Monarch
                                          Thanh Dinh

                                          Noted for reuse ^^

                                            • Re: VB and Monarch
                                              Grant Perkins

                                              You may want to consider that the original post is somewhat earlier than May 2014 (the date presented) as it comes fomr the previous forum and has been imported here.

                                               

                                              There have also been some changes in the way the Monarch can be "automated" in recent product developments.

                                               

                                              If you are using older versions of Monarch you may be ok with coded automation as discussed in the original thread.

                                               

                                              HTH.

                                               

                                               

                                               

                                              Grant

                                                • Re: VB and Monarch
                                                  Thanh Dinh

                                                  Thanks guy for your support. I know the Datawatch Monarch now changed. So if you can help me. Please show your upgrade code for Monarch 12  (that version I am using) or give me some advice about the change you know ^^

                                                  I feel very excited with this application and want to develop it

                                                    • Re: VB and Monarch
                                                      Wes Stewart

                                                      You should not be excited about developing with Monarch 12 because you can't.  They took automation away from Monarch 12.  Automation is only available with Data Pump or as a very expensive upgrade to Monarch 12. 

                                                        • Re: VB and Monarch
                                                          Olly Bond

                                                          Hello Wes,

                                                           

                                                          They took automation away two years ago from the basic licence with Monarch 11.5. The automatable version of Monarch now costs the same as the server product Automator(Data Pump).  That's not fundamentally a bad thing - there's a huge benefit in automation and it's fair to ask the customer to pay something for it - but, with hindsight, perhaps it might have been communicated slightly more clearly.

                                                           

                                                          For a customer on maintenance, it's perhaps a little less than courteous to remove a feature without any announcement, and then to tell them that the price to have the feature restored is "on application", so not published anywhere, and then for the price to be over ten times what the original product cost.

                                                           

                                                          For a customer not on maintenance, I would have less sympathy. But it strikes me that it would save everyone (customers and salesmen) a lot of hassle if there was some simpler path - perhaps a limited licence at $10,000 instead of $25,000 - that would allow users upgrading from XP and Office 2003 a way forward without having to make the leap to server.

                                                           

                                                          I should stress that I think that automation is best done on a server, and that everyone should buy Automator, and that I'm very much looking forward to Automator 12.5 at the end of this month which will let users manage the models and projects in the Digital Object Repository.

                                                           

                                                          It's a shame that there's no up to date webcast or video about the benefits of automating report mining - it's been so helpful for so many of us, it would be nice if Datawatch could get the word out to other folk who are faced with the same challenges as us.

                                                           

                                                          Best wishes,

                                                           

                                                          Olly

                                                            • Re: VB and Monarch
                                                              Wes Stewart

                                                              I think you probably meant to respond to Dinh since I already mentioned that there was no automation in 12.  FYI I did buy the automation option for Modeler/Monarch 12 last month.  Luckily it was not even close to the price of Automater.  I have not implemented it as yet since I am hoping Datawatch comes along with a way to edit the binary model and project files en masse.  Reading you post it looks like Automater 12.5 might do that, but alas its not something I own.

                                                                • Re: VB and Monarch
                                                                  Gareth Horton

                                                                  Hi Wes,

                                                                   

                                                                  The new Monarch Utility in Modeler 12.4.2 will allow you to bulk edit DMOD and DPRJ, just like the old Monarch utility did for XMOD and XPRJ.

                                                                   

                                                                  The update is available from the support portal.

                                                                   

                                                                  Best regards

                                                                   

                                                                  Gareth

                                            • VB and Monarch
                                              elginreigner _

                                              Being so new to these forums, I guess I don't know what kinds of backgrounds or what kinds of positions of people I'm seeing here. QUOTE]

                                               

                                              FYI, my background is in VB/C and database design.