Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Excel
123quattro
charting
crashesgpfs
datamap
excel
interopoledde
links
misc
newusers
printing
programming
querydao
sdk
setup
templates
worksheet.functions
  
 
date: Tue, 26 Feb 2008 15:53:28 -0800,    group: microsoft.public.excel.interopoledde        back       


Passing arrays from Excel (VBA) to C# using COM interop   
Hi - I'm using VS2005/Excel 2007 and can pass scalars from Excel to a C#
class exposed with [ClassInterface(ClassInterfaceType.AutoDual)] and setting
the assembly to Register for COM Interop and all works fine until I try to
pass an integer array from VBA to C#: I initially get "Function or interface
marked as restricted, or the function uses an Automation type not supported
in VB" and when I add "ref" to the C# function I get "Type mismatch: array
or user defined type expected".

Does anyone know what the trick to use to allow passing arrays (and ideally
other data types, objects, and returning various data types to Excel) from
Excel to a C# assembly?

Thanks.

Jon.
date: Tue, 26 Feb 2008 15:53:28 -0800   author:   jlea

Re:Passing arrays from Excel (VBA) to C# using COM interop   
Check the type of the array elements.  You can look up what type of 
parameter is expected in the vba object explorer.

An int in c# is a Long in VBA, so you may need to change your array in VBA:

Dim MyArray(10) As Long

url:http://www.ureader.com/msg/1032244.aspx
date: Fri, 4 Jul 2008 07:36:11 +0800   author:   Gidders

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us