ExcelArgument could not be found...

Jun 21, 2013 at 8:33 PM
I have just started using Excel-DNA with C# and am trying to convert my COM DLL containing Excel functions to an XLL. I have followed the instructions to add reference to ExcelDNA.Integration.dll and have been able to compile and access some of the functions.

One of the functions I am trying to compile needs a range object to be passed as an argument as I need to check for the hidden cells and other properties of cells. When I declare the function like below, I am not getting the auto complete for ExcelArgument and typing it manually and compiling it results in error as the compiler cannot resolve the reference to ExcelArgument, it simply is not visible. What am I doing wrong ? Any help will be appreciated.

Thanks.
[ExcelFunction(Category = "ABW Functions", Description = "Function to calculate sum of visible cells.", IsMacroType = true)]
        public static string Sum_Visible_Cells(ExcelArgument(AllowReference = true))
{
}
Coordinator
Jun 21, 2013 at 11:17 PM
Hi Alex,

You attribute syntax is not right for the parameter. It looks something like this:
[ExcelFunction(Category = "ABW Functions", Description = "Function to calculate sum of visible cells.", IsMacroType = true)]
public static string Sum_Visible_Cells([ExcelArgument(AllowReference=true)] object myInput)
{
    ExcelReference myInputRef = myInput as ExcelReference;
    if (myInputRef is null)
    {
        // The formula did not have a reference ....
    }
    else
    {
        // Use myInputRef...
    }
}
-Govert
Jun 29, 2013 at 6:34 AM
Hi Govert,

Thanks very much for the prompt response and sorry for the late response.

I think my project references were corrupt in someway as, I was getting errors with other objects as well. I had to create a new project and copy the code over and add the references which made things work.

By the way I have a got a couple of questions, how do I test for the hidden property of a cell and how do I write to a a whole range from an array or a collection ?

Thanks again for your help.
Jul 24, 2013 at 5:13 PM
Any help please ?