Board index » delphi » Passing an array to VBA (Excel)

Passing an array to VBA (Excel)

Hello!

How do I pass an array from a Pascal-DLL to Excel?

My idea is to write fast code for a physics interface in Pascal,  
pass the results as an array to Excel and use Excel to display  
the results. I finally manage to pass integers, singles and  
doubles, but just single parameters.

The problem starts when I pass an array. In the MSD-Docu they
show examples for interfacing with C where they use SAFEARRAYS
and calls to the SDK. Besides that it says an array is passed
from VBA to C as a pointer to a pointer. I tried some coding, but
didn't get too far (garbage values arrived when I passed arrays  
from VBA to Pascal, Excel produced GPFs when I passed them from  
the DLL to Excel).

Thanks for your help.

                Christian Koch

 

Re:Passing an array to VBA (Excel)


Quote
Christian Koch (c...@akg.th-darmstadt.de) writes:
> Hello!

> How do I pass an array from a Pascal-DLL to Excel?

> My idea is to write fast code for a physics interface in Pascal,  
> pass the results as an array to Excel and use Excel to display  
> the results. I finally manage to pass integers, singles and  
> doubles, but just single parameters.

> The problem starts when I pass an array. In the MSD-Docu they
> show examples for interfacing with C where they use SAFEARRAYS
> and calls to the SDK. Besides that it says an array is passed
> from VBA to C as a pointer to a pointer. I tried some coding, but
> didn't get too far (garbage values arrived when I passed arrays  
> from VBA to Pascal, Excel produced GPFs when I passed them from  
> the DLL to Excel).

> Thanks for your help.

>                 Christian Koch

  Do you have the Excel Development Kit?

The definition of the various parameters  that Excell uses in external
function call is definied in the book. Although they are in C, conversion
to Delphi records (not classes) should be straightforward.

--
Bill Royds           az...@freenet.carleton.ca    
Ottawa, Ontario      ROY...@EM.agr.ca          Scientific Software Support

Other Threads