Both the setreportfile and setmodelfile methods return boolean values when called. (I use v502 Std - YMMV)
For instance, you could code the following:
boolReportOK = objMonarch.setreportfile(strReport, False)
if boolReportOK then
boolModelOK = objMonarch.setmodelfile(strModel, False)
if not boolModelOK then
msgbox "Invalid Model File."
boolSuccess = False
msgbox "Invalid Report File."
boolSuccess = False
if boolSuccess then
'continue with normal processing
end if[/font][/quote]I've used this approach many times.
Hope this helps,
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.
boolOpenMod = MonarchObj.SetModelFile(strModName)[/font][/quote]This line returns the "Wrong number of arguments or invalid property assignment" error:
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?
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,