compiling error upon open excel and isMacroType=1

Jun 28, 2014 at 7:42 AM
Edited Jun 28, 2014 at 7:46 AM
When i open excel..
There was an error in loading the add-in First Add-In (C:\Users\alien3d\Documents\Visual Studio 2012\Projects\MyLibrary\MyLibrary\bin\Debug\MyLibrary-AddIn64.xll):
c:\Users\alien3d\AppData\Local\Temp\2xivlvsh.0.cs(1391,10) : error CS0246: The type or namespace name 'ExcelFunctionAttribute' could not be found (are you missing a using directive or an assembly reference?)
When i compile in visual studio 2012 desktop version okay.
And when i set isMacrotType=1
How do i access the method/function in microsoft excel vba macro ?
** Your excel-dna code just nice... i just learning it c# just 3 days :)
Jun 28, 2014 at 8:12 AM
using ExcelDna.Integration;
Jun 28, 2014 at 8:14 AM
that's already put.. above.. in visual studio .okay.. i will try to build test .net framework . might be that issue reference. . 3.5 dynamic out.. trying 4.0 now.
Jun 28, 2014 at 8:20 AM
It look like you are using the Excel-DNA NuGet package, but you also have some code in the .dna file.

Can you start again with a fresh 'Class Library' project, then add the NuGet package and check that it works?

Jun 28, 2014 at 8:34 AM
Ya.. the culprit is is code in .dna file. I put last the original code into .dna file.Are it suppose necessary ?
This what i doing with excel-dna .

How about isMacroType =1 .. How do access it via vba in microsoft excel

** when i try some code vba,udf work but in load when open the excel.. in doesn't effect and can said to user,please press ctrl +alt+shift+f9 something.. :)
Jun 28, 2014 at 8:38 AM
You don't need to have code in the .dna file, you can put everything in your compiled assembly.

IsMacroType=true affects the registration of your function, but is an advanced feature that you probably don't need.

I don't understand the rest of your question.

Jun 28, 2014 at 8:54 AM
Edited Jun 28, 2014 at 8:56 AM
i got one function checking user access from server upon opening Microsoft Excel and it will return either each worksheet can be read only or can be changed.
So i need to know it is isMacroType=1 mean i can code in vba and access the UDF function ?
If can access it how ?
If can access it can the UDF don't appear in excel sheet and only appear in the VBA only ?
Jun 28, 2014 at 9:02 AM
Edited Jun 28, 2014 at 9:02 AM
Maybe this should not be a UDF but something you run in your AutoOpen() or in a macro.

You can add:
public class MyAddIn : IExcelAddIn
    public void AutoOpen()
        // This runs when the add-in is loaded
        // call your sheet checking macro here

    public void AutoClose()

public static class MyMacros
        [ExcelCommand(MenuName="Test AddIn", MenuText="DoStuff", ShortCut="^+D")]
        public static void DoTheStuff()
            // This is a macro (not a UDF worksheet function) so it can change the worksheets and fully interact with the Excel object model
Marked as answer by alien3dx on 6/28/2014 at 2:04 AM