View Single Post
  #3   Report Post  
newOLE
 
Posts: n/a
Default

Harlan

thanks for the code. i tried it but always get this error:

Win32::OLE(0.1502) error 0x800a01a8
in METHOD/PROPERTYGET "" at valueTRS.pl line 40

and the code at line 40 is:

$Sheet-Run("myown"); # calculate all those rows

do you know what's going on?

-R



"Harlan Grove" wrote:

newOLE wrote...
I have an existing perl script that opens an excel sheet and writes stuff in
it.

but i cannot make it run a VB function that is inside it.

can you send me a code sample for executing a VB function in Excel using perl


Opens an *existing* workbook that contains VBA code in general modules?
If so, you should be able to use the Excel application class's Run
method. This works for me.


# xl_example.pl
use Win32::OLE;
$xl = Win32::OLE-CreateObject("Excel.Application");
$wb = $xl-Workbooks-Open('d:/test/deleteme.xls');
$xl-Run('foo'); #runs Sub foo
$zz = $xl-Run('bar'); #runs Function bar and stores its result
print $zz, "\n";
undef $wb;
undef $xl;