Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Using Win32::OLE and Excel - Tips and Tricks

by Anonymous Monk
on Jun 25, 2002 at 17:06 UTC ( #177139=note: print w/ replies, xml ) Need Help??


in reply to Using Win32::OLE and Excel - Tips and Tricks

Very good and useful article!!! By the way, I'm using it to update values on Excel, but I'd like to know if it's possible to update a cell while the excel file is open. I tried the simple way :
my $oExcel = Win32::OLE->new('Excel.Application','Quit');
my $oBook = $oExcel->Workbooks->Open("$excelFile");
my $oSheet = $oBook->Worksheets(1);
...
$oBook->Save;
$oBook->Close;

But it doesn't seem to work...
Any idea????
Thanx


Comment on Re: Using Win32::OLE and Excel - Tips and Tricks
Re: Re: Using Win32::OLE and Excel - Tips and Tricks
by cacharbe (Curate) on Jun 25, 2002 at 17:31 UTC
    I'm not sure that I understand your question. ALL of the above code assumes that the worksheet is open (Either by creating a new one, or by opening an existing one).

    Are you getting some kind of error, or are you not seeing what you expect? The code that you seem to have omitted would probably help me determine what the matter is, and don't forget to use <CODE> </CODE> tags, it makes for much easier reading.

    C-.

    ---
    Flex the Geek

      In fact, my problem is more about Excel rather than perl (I think).
      I was wondering if there is an option so when my perl program update a value in a cell I can see it immediately in Excel (the file is always open on my desktop)
        If its always open on your desktop, make sure that you are only using the current, open instance of Excel, set your worksheet=ActiveSheet and don't close the worksheet or workbook before terminating your script.
        my $Excel = Win32::OLE->GetActiveObject('Excel.Application')|| die "You gotta have it open first!!\n"; my $Sheet = $Excel->{ActiveSheet};

        C-.

        ---
        Flex the Geek

Re: Re: Using Win32::OLE and Excel - Tips and Tricks
by bkenik (Initiate) on Apr 10, 2004 at 23:54 UTC
    The excel must be opened by the script. if the file is already opened the script will fail. In other words your script cannot modified an opened file if it was not opened by your script

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://177139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-11-21 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (104 votes), past polls