This will open, recalculate the sheet, save and close the sheet. What I can't figure out is how to get a value from the mathcad sheet into the perl program. When I run the code it does not give me any errors. The results are as follows:#!/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;
C:\>perl "C:\documents and settings\aaron.verellen\desktop\trial.pl
C:\Program Files\Mathsoft\Mathcad 12\mathcad.exe
Congratulations the file is open ;P
Name: trial.xmcd
number =
The mathcad sheet is simple:
number:=2
poly(x):=x^2+2
poly(number)=6
Does anyone have any guesses as to why the value is not getting back to the perl program? Again, any guesses or help is much appreciated.
Aaron
In reply to Re^2: WIN32::OLE interface to Mathcad
by forgedascendant
in thread WIN32::OLE interface to Mathcad
by forgedascendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |