appleglaze28 wrote:I'd like to ask...is there any guidelines on how the TM1 Macro Functions are written like for there are some functions when you look at the referene guide they show the sample with the "=" infront of the syntax or function like =VUSLICE,=T_CREATE but there are some function like T_SAVE which are ran by write Applicaiton.Run ("T_SAVE"). I'm still not too familiar with VBA.
To a large extent you need to ignore the =VUSLICE style syntax.
Macro functions are so named because they were originally intended to be used with what's now known as the Excel 4.0 macro language (also known as XLM), which was a forerunner of VBA. Those macros were stored in Excel macro sheets which you can still insert into an Excel workbook (right click on a sheet tab and select "Insert...", and you'll be able to see them), but for practical purposes support for that type of macro ended with Excel 2000. (You can still run them if they already exist in a workbook, edit them and you can still call some Excel 4 macro functions via the ExecuteExcel4Macro method of the Application object. However it's probably been years since anyone (other than a hermit living in a cave with an 80386) has written a new Excel 4 macro.)
What you need to understand is that the =VUSLICE style syntax represents what the syntax
was with Excel 4.0 macros.
As Martin stated, the VBA syntax is
always Application.Run("MacroName", {Macro Arguments}). Some people omit the Application object since it's implied in the Run method; I don't, because I regard it as being a bit sloppy. If the macro function does return a value then as Martin said you return it from the Application.Run method. You'll
never return it directly from the function itself in VBA using the =VUSLICE style syntax.
This is kinda-sorta explained at the head of the relevant help page; the section titled "Accessing macro functions from Excel versions 5 and 7" takes you back to the versions where the XLM language was predominant (7 was Excel 95, when VBA first emerged from the primordial ooze, but it obviously took a while for XLM code to be converted), "Accessing macro functions from Excel version 8 and later" is for Office 97 and later which still support XLM code but only to a limited extent, and "Accessing macro functions from VBA modules" tells you essentially the same thing that Martin did.
I'm not going to bag out Iboglix for failing to update this page since it does correctly apply to the historical functions; the only problem is that XLM / Excel 4 macros were all such a long time ago now that you need to be a computer archaeologist to be able to remember them in that context. I think it's probably time to at least rewrite the page to show the VBA syntax as the predominant one, since I can understand how it can be confusing to someone who has never worked with the old language.