Hi Bobby,
UDF functions are registered in Excel as either Class 1
(IsMacroType=false) or Class 2 (IsMacroType=true). Class 1 UDFs are
more restricted as to which Excel functions can be called - in general
only worksheet functions can be called from Class 1 UDFs, while Class
2 UDFs can also call most macro functions, like GET.DOCUMENT
(xlfGetDocument) in this case. Only real macros (Class 3), which in
ExcelDna are methods with return type void, can call xlSet to set the
values of other cells. (Read
http://msdn.microsoft.com/en-us/library/bb687835.aspx).
For this function, if you had marked the function as IsMacroType=false
(or left it out - false is also the default), the xlfCaller and
xlSheetNm calls would be fine, but the xlfGetDocument calls to
retrieve the path would fail.
Note that you should also add some error checking (or dealing with the
results from xlfGetDocument better) for the case where the document is
not yet saved.
Hope this makes sense.
Regards,
Govert
> > - Show quoted text -- Hide quoted text -