The objects, methods, and properties are thoroughly documented in the Excel VBA help file. It is not installed in a default installation of Office, so you may (or may not) already have it installed. You'll want to at least familiarize yourself with Excel's object model (Application->Workbooks->Worksheets->Range->...) Also, look at the OLE Browser included with AS Perl.
As far as Perl documentation of OLE, ActivePerl-WinFAQ12.html should be available locally - if not, it's on the Active State website. perldoc Win32::OLE provides some useful information, too.
As far as converting VB syntax in the help file to perl, the basic rules are:
- Methods (as defined in the helpfile) are called just like your example, (e.g., Workbooks->Add()).
- Properties (again, as defined by MS) are accessed with curly brackets:
$sheets[0]->{Name}
- For named constants, use an anonymous hash or hashref:
$xls->ActiveChart->Location({ Where => xlLocationAsObject, Name =>'Sheet1'});
The first thing I do usually is record a macro that does the basics of what I want. Then, I use Win32::OLE::Const 'Microsoft Excel'; to import all Excel constants, so I can copy examples from the from macro I've recorded (or from the helpfile) without looking up the values of the constants. Then I can translate until it all works like I expect it.
All in all, controlling Excel is quirky at best, and ugly at its worst. I have some notes I've taken, but they aren't formatted in any useful way. If you want to see them, let me know.
Hope all this helps in some small way...
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.