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

Thanks. It turned out my error was i was closing the book before that.

New question: how do i execute a function written with arguments passed and
lay out its return parameters on a range of cells. This function is an Excel
add-in. Does that require special processing?

-R

"Harlan Grove" wrote:

"newOLE" wrote...
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?

....
"Harlan Grove" wrote:

....
# 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;


Is your $Sheet variable a reference to a worksheet object? If so, that's
your problem. Excel's Worksheet class doesn't have a Run method, Excel's
Application class does. If you look at my code above you'll see that I call
the Run method from the Excel application object $xl. Either you need use
Run directly from an Excel application object reference or by deriving one
from a worksheet object reference, i.e.,

$Sheet-Parent-Parent-Run('myown');