6 Replies Latest reply: May 15, 2014 9:54 AM by Mark Huston RSS

    Is there a Verify method for VBA?

    Mark Huston

      Is there a way to apply a "Verify" method programmatically when the report and model have been opened? It would be great to be able to test the model, using Monarch's "Verify" functionality, each time a new report is opened.

        • Is there a Verify method for VBA?
          Data Kruncher

          Mark,

           

          Both the setreportfile and setmodelfile methods return boolean values when called. (I use v502 Std - YMMV)

           

          For instance, you could code the following:

          [font="courier"]boolSuccess = True

          boolReportOK = objMonarch.setreportfile(strReport, False)

          if boolReportOK then

              boolModelOK = objMonarch.setmodelfile(strModel, False)

              if not boolModelOK then

                 msgbox "Invalid Model File."

                 boolSuccess = False

              end if

          else

              msgbox "Invalid Report File."

              boolSuccess = False

          end if

           

          if boolSuccess then

             'continue with normal processing

          end if[/font][/quote]I've used this approach many times.

           

          Hope this helps,

          Sandy

          • Is there a Verify method for VBA?
            Mark Huston

            Dang.

             

            I get a run-time error 450: "Wrong number of arguments or invalid property assignment".

             

            This line works OK, it returns true because the model was found.

            [font="courier"] 

                    boolOpenMod = MonarchObj.SetModelFile(strModName)[/font][/quote]This line returns the "Wrong number of arguments or invalid property assignment" error: 

            [font="courier"]        boolOKMod = MonarchObj.SetModelFile(strModName, False)[/font][/quote]Any ideas?

            • Is there a Verify method for VBA?
              Steve Caiels

              Hi,

               

              As far as I'm aware, the boolean value is only to "verify" that the file exists.  I don't think it verifies that the model is suitable for the report in question (like clicking the verify button in monarch).  I may be wrong, I'm not an expert on vb.

               

              Cheers

              Steve

              • Is there a Verify method for VBA?
                Data Kruncher

                Mark,

                Steve is correct. My example only is only reporting that the files exist and could be opened by Monarch. It does not test to see that you've opened the proper model file for your report, or that the model is extracting data as you expect it to.

                 

                When I have more time, I can pursue this and will post my result here, but, sorry, I can't do that now.

                 

                Any quick ideas, group?

                 

                Sandy

                • Is there a Verify method for VBA?
                  Nick Osdale-Popa

                  Your best bet will probably be the FindText() method.  If you know that a report is supposed to have certain static information such as a report title, then you can use the FindText() to search for that information and generate an error if it does not find it.

                   

                  Just my 2c worth.

                  • Is there a Verify method for VBA?
                    Mark Huston

                    Truth be told, I doubted that a "verify" method for VBA existed, but I've been surprised before by some very ingenious techniques that have been posted on this list so I thought I'd throw it out to you folks anyway. I'm using V6 Pro.

                     

                    I was curious because I frequently use Monarch's "Verify" function in the Report view, after applying the model, to make sure the data isn't exceeding the field size. This is essential when first building a model. I also find it handy to check again from time to time, in my environment you never know when a report is going to change without warning. It would be nice to have this function available to VBA ... maybe in a later version? (Hint hint, Mike U.)

                     

                    Though I still am a bit perplexed as to why Data Kruncher is able to use

                    [font="courier"] boolModelOK = objMonarch.setmodelfile(strModel, False)[/font][/quote]and not get the same "wrong number of arguments" error I get when I use  [font="courier"] boolOKMod = MonarchObj.SetModelFile(strModName, False) /font[/quote]Thanks again,

                    Mark!