http://qs321.pair.com?node_id=526131

ceashure has asked for the wisdom of the Perl Monks concerning the following question:

source code: http://www.adp-gmbh.ch/perl/word.html (second one down) I need help getting this code to work with the Microsoft Word 11.0 (2003) object libraray. A big part of it has to do with the fact that this code uses mso.* objects when most objects in the 2003 object library do not start with mso (msoFalse, msoTrue, msoTextOrientationHorizontal , etc) anyone have previous experience with this? Do i need to install word 97? ANY help is appriciated Thanks!

Replies are listed 'Best First'.
Re: Win32::OLE used with office 2003
by planetscape (Chancellor) on Jan 30, 2006 at 17:46 UTC

    In my experience, most Monks here are (justifiably) leery of clicking on external links to read someone's source code. You will probably get a better response if you post the code you are actually using (especially any modifications you've made!) and either a sample of your data, or your input and expected/actual ouput. You may wish to read at least a few of the links you'll find here, to get a good idea of how the Monastery works.

    Super Search is your friend. Use it with terms like "object browser", for example, to turn up nodes like this one, which will show you how Perl tools can help you with questions about MS Office Object Models. You will also find a number of nodes dealing with using Perl to automate MS Word. Don't give up if at first you don't find any; modify your terms and try again!

    Finally, the general rule is, yes, if you plan on automating part of the MS Office Suite with Perl (or any other language, even VB(A)), you do need that component installed.

    HTH,

    Update: wfsp just pointed out to me that you were in the ChatterBox yesterday asking about this... He thinks you might be having version problems... So check that the code you are using/modifying is compatible with the version of Word you have. Some code can be ported; some can't.

    planetscape
      In my experience, most Monks here are (justifiably) leery of clicking on external links to read someone's source code.
      Why do you say this? I am just curious.

        Um, I've been under the weather and doubtless could have phrased things better. ;-)

        In my experience, most Monks prefer code to be posted inline with the writeup; at least, most responses I have read to writeups without code admonish the OP to provide it.

        I have also noted many replies indicating a reluctance to follow external links; perhaps it is just because such tend to break easily.

        My methods certainly are not scientific. I was merely going by what I had noticed in the past.

        HTH,

        planetscape
Re: Win32::OLE used with office 2003
by john_oshea (Priest) on Jan 30, 2006 at 18:12 UTC

    You'll have to determine the new equivalents to the mso* objects - hopefully this is documented somewhere on MSDN in fact, this page on Migration From Office 97 to Office 2003 looks promising. If not, you'll have to go through the VBA object inspector in Word 2003 and try to figure it out.

    I also seem to remember somewhere that Word 2003's native format was (or could be) XML-based, so you could just ignore automating Word altogether and create files in the format it's expecting. Especially so as the link you reference just seems to be creating a Word document, and isn't doing anything "interactive" with Word. Mind you, if the Word xml document format is anything like I suspect it might be, then that way could lead to madness ;-)

    Hope that helps.

Re: Win32::OLE used with office 2003
by blm (Hermit) on Jan 31, 2006 at 00:40 UTC
    What you need to do is update the lines that pull in the constants like msoFalse Here are all the 'use' lines that I had to use to get second example to work with Office 2003:
    use warnings; use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Office 11.0 Object Library'; use Win32::OLE::Const 'Microsoft Office Runtime 1.0 Type Library'; use Win32::OLE::Const 'Microsoft Word 11.0 Object Library';