Hello Govert
I was trying to use a custom public enum in a UDF but Visual Studio seems not to accept them.
Given Message is “Initialization [Error] Method not registered…” and the UDF is not enlisted in the formula
I was also trying to insert the enum (in addition to the creation of a public enum in a class) as Names in the Workbook
(In the WorkBookActivate Event I wrote:
CurrentExcelApplication.ActiveWorkbook.Names.Add(Name:="Sfondo", RefersToR1C1:="=0")
CurrentExcelApplication.ActiveWorkbook.Names.Add(Name:="Testo", RefersToR1C1:="=1")
..but there is still the same error
Is it there a way to bypass this?
Thanks
Alberto
Hi Alberto,
The basic Excel-DNA library doesn’t have any special enum support, but the Registration extension (https://github.com/Excel-DNA/Registration ) allows you to add this. The parameter conversion there just does automatic enum <-> string conversion for enum parameters – the name-based approach might be nicer.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.
Hi Govert,
I included exceldna.registration as follows
1) In the .dna file:
<ExternalLibrary Path="AlanTools.dll" ExplicitRegistration="true" LoadFromBytes="true" Pack="true" ComServer="true" />
2) In the .AutoOpen Sub:
Dim functions = ExcelRegistration.GetExcelFunctions().ToList()
Dim Commands = ExcelRegistration.GetExcelCommands().ToList()
ExcelRegistration.RegisterFunctions(functions)
The Function is as follows
<ExcelFunction(IsVolatile:=True, IsMacroType:=True, Description:="Ritorna il colore dello Sfondo", Name:="XCOLORE")> _
Public Shared Function XColore(<ExcelArgument(AllowReference:=True, Description:="Cella di riferimento")> Indirizzo As Object, _
C As Enumerables.Colore) As Long
But I get nearly the same error: “Registration [Error] Method not registered due to unsupported signature: 'Func`3.Invoke' : DnaMarshalException - Unknown Data Type: AlanTools.Enumerables+Colore”
How can I registrate the ENUM?
I tried to include in the .GetExcelFunctions() but I don’t know how to do
Many Thanks
Alberto
Da: exce...@googlegroups.com [mailto:exce...@googlegroups.com] Per conto di Govert van Drimmelen
Inviato: venerdì 8 settembre 2017 17:28
A: exce...@googlegroups.com
Oggetto: RE: [ExcelDna] Custom ENUM with UDF