Apr 19, 2012 at 2:38 PM


I am still try to undertand Excel-DNA, what IsMacroType do? When should I set IsMacroType to true?



Apr 19, 2012 at 2:49 PM

Hi Stephane,

Marking a function with IsMacroType=true changes the registration string that Excel-DNA sends to Excel - it adds a # to the string thus denoting a "macro sheet equivalent function". Such functions are in Class 2 and can call various Excel information functions "that return a value but perform no action that affects the workspace or any open workbook". (Some details here: and if you search for xlfRegister).

The main reason you'd use IsMacroType=true is so that your function can read from other parts of the sheet - suppose you were implementing a version of the =OFFSET function. Also if you need to call the GET.XXX information functions, e.g. to know some workbook settings, you need this setting on. Such functions still cannot call xlSet, or change other parts of the sheet. 

A potential catch with  IsMacroType=true is that such functions are sometimes automatically considered Volatile by Excel, and hence will recompute more often than you expect.

I'd suggest you not apply this setting to your functions unless you have a particular reason which forces you to set it.



Apr 19, 2012 at 2:56 PM

thanks a lot! Make since now.