#!/usr/ym/util/perl use Win32::OLE; #Perl "C:/documents and settings/aaron.verellen/desktop/trial3.pl" Win32::OLE->Option(Warn => 2); #use existing instance if excel is already running eval {$EX = Win32::OLE->GetActiveObject('Excel.Application')}; die "Excel not installed" if $@; unless (defined $EX) { $EX = Win32::OLE->new('Excel.Application', sub{$_[0]->Quit;}) or die "Unable to start Excel"; } #Open specific worksheet and tab my $filePath = 'C:\Documents and Settings\aaron.verellen\Desktop\MathCad Bridge.xls'; my $WB = $EX->workbooks->Open($filePath); my $S = $WB->worksheets("Caculations"); $S->activate(); #Set values on the worksheet $S->range("A1")->{value} = 16; $S->range("B1")->{value} = 17; $S->range("C1")->{value} = 18; #call macro to process data $EX->run("Bridge_To_MathCad"); #get the answers from the worksheet and close the excel sheet $output1 = $S->range("A2")->{value}; $output2 = $S->range("b2")->{value}; #close excel sheet $WB->close; #return the values print "($output1, $output2)\n";