Thanks for your reply. I was searching on the internet. I found a webpage. Somehow, I missed the address. There was explanation on this problem. I am sorry, I am unable to write the reference.
The listing is the following, which works.
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Math
<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)> _
Public Class Class1
'This is for automatically register the function in Excel
<ComUnregisterFunctionAttribute()> _
Public Shared Sub RegisterFunction(ByVal type As Type)
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type))
End Sub
'This is for to unregister the function from Excel
<ComUnregisterFunctionAttribute()> _
Public Shared Sub UnRegisterFunction(ByVal type As Type)
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type))
End Sub
Private Shared Function GetSubKeyName(ByVal type As Type) As String
Dim s1 As String
s1 = "CLSID\{" & type.GUID.ToString().ToUpper() & "}\Programmable"
Return s1.ToString()
End Function
' this is Excel custom formula "MyTestFormula"
Public Function myTestFormula(ByVal anyNumber As Double) As Double
Dim result As Double = anyNumber * 2
Return result
End Function
Public Function myFun(ByVal x1 As Double, ByVal x2 As Double) As Double
Dim myFuns As New MyFunctions
myFuns.GetX1 = x1
myFuns.GetX2 = x2
Return myFuns.Add
End Function
End Class
<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)> _
Public Class MyFunctions
Private x1 As Double
Public Property GetX1() As Double
Get
Return x1
End Get
Set(ByVal value As Double)
x1 = value
End Set
End Property
Dim X2 As Double
Public Property GetX2() As Double
Get
Return X2
End Get
Set(ByVal value As Double)
X2 = value
End Set
End Property
Public Function Add() As Double
Return Abs(x1 + X2)
End Function
End Class
Hopefully, this may be useful to others.
There are also some references which are talking about the new technology: Microsoft.Office.Excel.Server.Udf.dll for defining UDF. I have to still look on it.
Thanks for your help.
Mahendra
-----Mensaje original-----
De: exce...@googlegroups.com [mailto:exce...@googlegroups.com] En nombre de Govert van Drimmelen
Enviado el: miércoles, 13 de julio de 2011 02:41 a.m.
Para: Excel-DNA
Asunto: [ExcelDna] Re: ExcelComAddInHelper.LoadComAddIn Help
Hi,
-Govert
public AddIn()
{
}
}
public void AutoClose()
{
}
}
]]>
</DnaLibrary>
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceldna?hl=en.
In my last email I proposed a solution for my problem, the use the .NET class as a variable in creating a UDF in Excel. The solution works well on the computer on which the UDF was created. It creates a library "MSCOREE.DLL" for the UDF. I am looking for it (library) since last two days. I have no idea what is all this. If I could not find any solution for it before this Friday, I will quit programming in Excel. I am not an expert in programming. It is a tool for me to perform some mathematical calculations.
It is really amazing that the Microsoft can do such drastic changes. We all are working to resolve it instead of them (Microsoft). Even they cannot write an appropriate user manual for their products (software). To look something on their webpage is equivalent to the wastage time for users like me (or at least I found that). It was great hassle for me to change from VB6 to .NET. Of course there were many problems with VB6.
I am really sorry to propose the solution before investigating in detail.
Thanks for reading it and your help.
Mahendra
-----Mensaje original-----
De: exce...@googlegroups.com [mailto:exce...@googlegroups.com] En nombre de Mahendra Pal Verma Jaiswa
Enviado el: miércoles, 13 de julio de 2011 02:35 p.m.
Para: exce...@googlegroups.com
Asunto: RE: [ExcelDna] Re: ExcelComAddInHelper.LoadComAddIn Help