With they I have achieved making some dll functions without parameters available for excel as User Defined Functions,
but they don't work with parameters. Worst, when I changed the name of the class, or the main namespace, they stopped working, even after I restored the original names.
I do not get it. Have no idea what is wrong.
I attach a very basic VB.NET 2008 project. It contains two functions:
Code:
Public Function TestWithoutParameters() As String
Return "It looks like it works!"
End Function
Public Function TestExcel(ByRef PerÃ*odo As Integer, _
ByRef Precipitación() As Double) As Double()
Return Precipitación
End Function
They don't work. I think is a problem with COM, but no idea.
¿Can someone give me a hint?
Microsoft gives little help.
I attach the project.
This is the main code:
Code:
Imports System.Math
Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Namespace MyNamespace
<Guid("d2f1d268-a846-4094-9e7f-c9f0be0ab44d")> _
<ClassInterface(ClassInterfaceType.AutoDual), _
ComVisible(True)> _
Public Class FuncionesSPI
Public Sub New()
End Sub
Public Function TestWithoutParameters() As String
Return "It looks like it works!"
End Function
Public Function TestExcel(ByRef PerÃ*odo As Integer, _
ByRef Precipitación() As Double) As Double()
Return Precipitación
End Function
'Para interoperabilidad con excel:
<ComRegisterFunctionAttribute()> _
Public Shared Sub RegisterFunction(ByVal t As Type)
Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("CLSID\{" + t.GUID.ToString().ToUpper() + "}\Programmable")
End Sub
<ComUnregisterFunctionAttribute()> _
Public Shared Sub UnregisterFunction(ByVal t As Type)
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey("CLSID\{" + t.GUID.ToString().ToUpper() + "}\Programmable")
End Sub
Private Shared Function GetSubkeyName(ByVal type As Type) As String
Dim S As New System.Text.StringBuilder()
S.Append("CLSID\{")
S.Append(type.GUID.ToString().ToUpper())
S.Append("}\Programmable")
Return S.ToString()
End Function
End Class
End Namespace
Last edited by Marraco; July 30th, 2008 at 12:44 PM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.