I am writing a shortkey event handler to implement activity when the user types in a function and then presses a keyboard shortcut.
As I understand ExcelApp.Evaluate("myFunc()") is the way to go.
However, within my XLL Addin, myFunc returns type object[,] whereas Evaluate() only returns type object
Is there any way I can convert object to object[,]?
EDIT:
object myArray = ExcelApp.Evaluate(functioname);
if (myArray is object[,])
{
int height = myArray.GetLength(0); //Does not recognise GetLength, even though it's an object[,] method
Evaluatemay be the way to go, or it may be not, depending on what exactly you want.If you want to actually evaluate things like addresses, then yes, it is.
Otherwise, there’s
Application.Run.As for the question, Excel’s functions return
OLE Variant, which may contain/refer to anything, including an array. From Excel side, handling this does not require any effort from the code.EDIT: