Greetings! I have a script that mucks around in Excel, which I've been using since Office 2000. Suddenly and tragically, I am having issues with Excel 2013 users. I need to make the workbook visible, otherwise when I save the Excel file, the workbook will be hidden when the user tries to open it. I have used the code below successfully for years to accomplish this. I have marked the offending line below in the code. When this is used with Excel 2013 on Win7 x64, I get the following error:

Win32::OLE(0.1712) error 0x8002000b: "Invalid index" in METHOD/PROPERTYGET "Windows" at blah.pl line 91. Can't use an undefined value as a HASH reference at blah.pl line 91.

Has anyone else run into this, or have any suggestions?

use strict; use Win32::OLE qw(with); use Win32::OLE::Const 'Microsoft Excel'; sub open_sheet { my $file = shift; my $workbook = Win32::OLE->GetObject( "$file" ) || die "Could not locate $file.\n"; my $excelApp = $workbook->{Application}; $excelApp->{Visible} = 1; # ****this next line no longer works in Excel 2013**** $excelApp->Windows( $workbook->{Name} )->{Visible} = 1; # ^^^^bad! .... }

Thanks!


In reply to Making workbook visible with Excel 2013 by chinman

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.