Originally this was done through an activeX object that connected to
the database. I have been given the task of writing code that
accesses a server service via remoting. I have successfully completed
this task. I am able to retrieve data from the SQL server into a VSTO
add-in. I am now working on getting the data from managed code to the
original macro templates so that I don’t have to rewrite all of the
macros.
To shorten an already lengthy description, I am having a problem
passing a VBA variant array into my VSTO add-in. I am able to pass a
string so I know that my VBA code is talking to my VSTO add-in it just
doesn't like the variant type and throws a Type Mismatch error.
My VBA code:
Public Sub ProcWM_GetAppealJudge(ByVal varP() As Variant, ByRef varR()
As Variant)
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns("BIIA_Addin")
Set automationObject = addIn.Object
automationObject.GetData "ProcWM_GetAppealJudge", varP(), varR()
End Sub
My VB.Net Code:
Imports System.Data
Imports System.Runtime.InteropServices
Imports Word = Microsoft.Office.Interop.Word
<System.Runtime.InteropServices.ComVisibleAttribute(True)> _
<System.Runtime.InteropServices.InterfaceType( _
ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface SIAdapterInterface
Sub GetData(ByVal sProcName As String, ByVal vParam() As
Microsoft.VisualBasic.VariantType, ByRef vResults() As
Microsoft.VisualBasic.VariantType)
End Interface
<System.Runtime.InteropServices.ComVisibleAttribute(True)> _
<System.Runtime.InteropServices.ClassInterface( _
System.Runtime.InteropServices.ClassInterfaceType.None)> _
Public Class SIAdapter
Implements SIAdapterInterface
Public Sub GetData(ByVal sProcName As String, ByVal vParam() As
Microsoft.VisualBasic.VariantType, ByRef vResults() As
Microsoft.VisualBasic.VariantType) Implements
SIAdapterInterface.GetData
End Sub
End Class