1

I am currently trying to pass an array of objects as a result to VBA but Excel is complaining the following:

'Function or interface marked as restricted, or the function uses an automation type not supported in Visual Basic.'

I have looked around on the internet and have seen similar issues but not to one I am trying to do.

My function is declared as follows:

<ComClass(Class1.ClassId, Class1.InterfaceId, Class1.EventsId)> _
Public Class Class1

#Region "COM GUIDs"
...
#End Region

Public Sub New()
    MyBase.New()
End Sub

Private Const AT_HOME As Boolean = True
Public Function hello() As System.String()
    Dim a(10) As String

    a(0) = "hello"
    a(1) = "Goodbye"

    Return a
End Function
Public Function CallArray(ByVal serviceName As String, _
                                    ByVal effectiveDate As String,
                                    ByVal serviceParams() As System.Object,
                                    ByRef ArrayRes() As System.Object) As System.Boolean

VBA is complaining about the System.Objects my question is how the heck are you supposed to pass and return arrays from .NET to VBA. Also the data that will be in the ArrayRes() is mixed type, its not just strings etc, its an array of arrays that can contain strings, integers doubles etc.

I chose VB .NET because I assumed it would be possible to map to VBA easier.

One last thing, if System.Object and Arrays in VB .NET is not the way, ie maybe theres another way via collections or lists, then Im open to that. I just need to get this data into VBA. Also I could move over to C# if needs be.

Thanks for any help or recommendations

4

1 回答 1

0

修复了传入的数据不是所需的格式,所以我创建了一个函数来格式化和处理数据

于 2012-05-07T19:24:21.050 回答