#!/usr/ym/util/perl use Win32::OLE; #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"; } #Figure out point of orgin and verify MC works my $h = $MC->fullname; print "$h\n"; #Open specific worksheet my $filePath = 'C:\Documents and Settings\aaron.verellen\Desktop\trial.xmcd'; $MC->{DefaultFilePath} = $filePath; my $WS = $MC->Worksheets->Open($filePath); if ($WS->{IsOpen}) { print "Congratulations the file is open ;P\n"; } else { print "DENIED: Try opening the file again\n"; } #prove the WS object my $Name= $WS->{Name}; print "Name: $Name\n"; #Retrieve a value from the worksheet my $varable = 'number'; my $value = $WS->GetValue($varable); print "$varable = $value\n"; $WS->Recalculate; $WS->save; $WS->close; #$MC->Quit;