Declaration Attributes

You are able to define the function wizard category as well as the function description and argument descriptions.
You can even provide a tooltip
These customisations can be made by adding .NET attributes to the function declarations.
link - github.com/Excel-DNA/ExcelDna/wiki/ExcelFunction-and-other-attributes


Function Category

The function category can be defined using the "Category" ExcelFunction attribute.

[ExcelDna.Integration.ExcelFunction(Category="NewCategory")] 
public static string udf_MYFUNCTION(string sText)
{
   return sText + sText;
}

Function Name

The function name can be defined using the "Name" ExcelFunction attribute.

[ExcelDna.Integration.ExcelFunction(Name="myFunction")] 
public static string udf_MYFUNCTION(string sText)
{
   return sText + sText;
}

Function Description

The function description can be defined using the "Description" ExcelFunction attribute.

[ExcelDna.Integration.ExcelFunction(Description="HelloWorld")] 
public static string udf_MYFUNCTION(string sText)
{
   return sText + sText;
}

Function Arguments

Each argument can have a description using the "Description" ExcelArgument attribute.
If you want the argument to have a different name, you can use the "Name" ExcelArgument attribute.

public static string udf_MYFUNCTION( 
   [ExcelDna.Integration.ExcelArgument(Description=@"Text Value")]
   string sText1,
   [ExcelDna.Integration.ExcelArgument(Description=@"(""A"") 22")]
   string sText2,
   [ExcelDna.Integration.ExcelArgument(Description=@"Arg(3)")]
   string sText3)
{
   return sText1 + sText2 + sText3;
}

IsMacroType


[ExcelDna.Integration.ExcelFunction(IsMacroType=true)] 


IsThreadSafe

A function can be specified as thread safe using the "IsThreadSafe" ExcelFunction attribute.
A Thread-safe function is a function that will work even when lots of different threads are executing it simultaneously.
The IsThreadSafe attribute can only be used when the IsMacroType attribute is set to False.
A function that is considered thread-safe can be called concurrently from different calculation threads.

[ExcelDna.Integration.ExcelFunction(IsMacroType=false, IsThreadSafe=true)] 

IsVolatile

When a function is volatile it will update when you press F9.
The IsVolatile attribute can only be used when the IsMacroType attribute is set to False.
This is not recommended and there are better ways of achieving the same thing.

[ExcelDna.Integration.ExcelFunction(IsMacroType=false, IsVolatile=true)] 

link - docs.microsoft.com/en-us/office/client-developer/excel/excel-commands-functions-and-states


IsHidden

The function can be hidden from the Functon Wizard using the "IsHidden" ExcelFunction attribute.
The function will not appear in the AutoComplete pop-up when entering formulas.
The function will still be available from VBA using Application.Run.

[ExcelDna.Integration.ExcelFunction(IsHidden=true)] 

IsExceptionSafe


[ExcelDna.Integration.ExcelFunction(IsExceptionSafe=true)] 


© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext