Working with Perl and Excel 2007 spreadsheets (on a windows XP Pc), I have used assignment statements such as
$excel->{ActivePrinter} = "Auto HP Deskjet 6500 Series on HOMEDELLTOWE
+R on Ne02:";
Frequently the problem has been to find out the ‘name’ of the variable to set – for example ActivePrinter.
Therefore I thought it would be useful if I could find out all the variables associated with $excel.
To this end I tried the following, hoping the $excel was a reference to a hash.
use strict ;
use OLE;
use Win32::OLE::Const "Microsoft Excel";
my ($excel, $workbook, $sheet, $jex);
$excel = CreateObject OLE "Excel.Application";
$workbook = $excel -> Workbooks -> Add;
print "before jex loop\n";
foreach $jex (sort {$a cmp $b} %$excel) {
print "$jex <$excel->{$jex}\n";
}
print "after jex loop\n";
This failed and I got a ‘windows’ error message saying that “perl.exe has encountered a problem and needs to close. We are sorry for the inconvenience."
What is the correct way of finding out what is ‘in’ $excel?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.