Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Win32::OLE used with office 2003

by ceashure (Initiate)
on Jan 28, 2006 at 03:28 UTC ( #526131=perlquestion: print w/replies, xml ) Need Help??

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

source code: (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.


    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.

      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.


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';

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://526131]
Approved by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2023-06-02 19:14 GMT
Find Nodes?
    Voting Booth?

    No recent polls found