Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Win32 OLE Excel 2003 question

by gibsonca (Beadle)
on May 05, 2009 at 19:42 UTC ( #762037=perlquestion: print w/replies, xml ) Need Help??
gibsonca has asked for the wisdom of the Perl Monks concerning the following question:

Windows XP, Perl 5.x, Win32 OLE, Excel 2003

1) After this script runs, and I open the newly created excel file, I can see that the 2nd row is selected, yet the freezepane is not active.

my $freeze_panes = $gExcel->ActiveSheet->Range("2:2")->Select; #$gSheet->Cells(2,2)->Select(); $gExcel->ActiveSheet->{FreezePanes} = $TRUE; # or 1 ..

2) The user occasionally orphans a copy of excel, and I'd like to be able to detect that a copy of excel is already running. This effort does not work (of course): Is there a way to detect an orphaned Excel? YOu have to delete it with windows task manager?

if ($Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit')) { print "\n123 \n"; } else { print "\n456 \n"; }

Replies are listed 'Best First'.
Re: Win32 OLE Excel 2003 question
by Corion (Pope) on May 05, 2009 at 20:24 UTC

    What is the value of $TRUE? I don't think it contains what you think it does.

    I'm not aware of any good way of preventing orphaned copies of Excel except not crashing your script.

      So you don't have trouble with freezepane? Great I won't give up. $TRUE is 1, tried using the following: = 1 ; = '1'; = "1"; = $TRUE; Crashing is caused by the user having a copy of excel running, unrelat +ed to the script, when the perl script is run. The involved files are + unique. So it would be best to know that excel is already running before the s +cript is run. I could error out nicely, instead of locking up an orph +aned version of excel.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://762037]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-10-22 16:50 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (274 votes). Check out past polls.