#!/usr/ym/util/perl use Win32::OLE; #Perl "C:/documents and settings/aaron.verellen/desktop/trial2.pl" Win32::OLE->Option(Warn => 2); #use existing instance if mathcad is already running eval {$MC = Win32::OLE->GetActiveObject('Mathcad.Application')}; die "Mathcad not installed" if $@; unless (defined $MC) { $MC = Win32::OLE->new('Mathcad.Application', sub{$_[0]->Quit;}) or die "Unable to start Mathcad"; } #Open specific worksheet my $filePath = 'C:\Documents and Settings\aaron.verellen\Desktop\testM12.xmcd'; my $WS = $MC->Worksheets; my $S = $WS->Open($filePath); #Set values on the worksheet $S->setValue('x',50); $S->setValue('y',60); $S->setValue('z',70); $S->Recalculate; my $answer1 = $S->getValue('output1'); my $answer2 = $S->getValue('output2'); print "($answer1,$answer2)\n";