Why do you want to activate the sheet? The simple answer to your question is "It shouldn't - regardless of Excel version". Your "use" statements seem strange to me. I would expect to see use Win32::OLE; somewhere, and this may be part of your problem. I'm also surprised by your statement that you are using Excel 7, a version that appeared in 1995. My guess is that the strange way you are setting things up means that a workbook is being created with no sheets (I thought this was impossible) or that no workbook is being created. Anyway, on XP Pro and Excel 10 (I use it all the time - it has functionality missing in later versions), the following code seems to me to do what you want.

use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; my $sht = $wb->Sheets("Sheet1"); $sht -> Range("B2") -> {Value} = 1234;

Regards,

John Davies

Update: if you really need to select the sheet - it can be necessary, rarely - $sht->Select; works for me.


In reply to Re: Perl and Excel 10 by davies
in thread Perl and Excel 10 by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.