forgedascendant has asked for the wisdom of the Perl Monks concerning the following question:

Good afternoon monks,

I have a question concerning the abilities of the Win32::OLE module. I would like to know if I could write code that would open something like mathcad or excel and keep it open after the code terminates?

The best I could come up with is below but mathcad terminates upon the ending of the code when I would like to to just remain open:

#Call MathCad 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"; $MC -> {Visible} = 1; }
Thak you for any help you are able to offer, Forgedascendant
  • Comment on Can Win32::OLE be used to perminatly open a object such as mathcad?
  • Download Code

Replies are listed 'Best First'.
Re: Can Win32::OLE be used to perminatly open a object such as mathcad?
by BrowserUk (Patriarch) on Apr 14, 2010 at 16:33 UTC

    Since you already have the code to attach to an existing instance, why not just start the application using

    system 1, '/path/to/mathcad.exe'; or system'cmd /c start /path/to/mathcad.exe';,

    first, then always attach to the existing instance?