Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Where is the Win32::OLE Docs

by gibsonca (Beadle)
on Oct 08, 2009 at 21:40 UTC ( #800104=perlquestion: print w/replies, xml ) Need Help??

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

Hi all,

Where do I find the complete information on what I can do with Win32::OLE, when modifying an M$ word document? For example, I found that following code on the web, and it works on my MS Word input file, but I would like to know 'the rest of the story'.

I'd like to know how the originally author figured this much out!

Thanks for your time!

$selection->{'Find'}->ClearFormatting; $selection->{'Find'}->{'Style'} = $doc->Styles('Title'); $selection->{'Find'}->{'Text'} = "app"; $selection->{'Find'}->Execute; $selection->{'Find'}->{'Replacement'}->{'Text'} = "B"; $selection->{'Find'}->Execute({Replace => wdReplaceAll}); $selection->{'Find'}->{'Forward'} = 1; # find next instance $selection->{'Find'}->Execute; $selection->{'Find'}->{'Format'} = 1; $selection->{'Find'}->Execute;

Replies are listed 'Best First'.
Re: Where is the Win32::OLE Docs
by CountZero (Bishop) on Oct 08, 2009 at 21:56 UTC
    I'd like to know how the originally author figured this much out!
    It must have been divine inspiration or access to a Microsoft Software Development Kit.


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Where is the Win32::OLE Docs
by davies (Prior) on Oct 08, 2009 at 23:06 UTC
    I'm writing something to hack Excel (I can't help specifically with Word), and one of the techniques I have found useful is to write a VBA prototype. That way, you can work out the VBA references using intellisense, which typically gives you all the available options. Then it's relatively simple to rewrite the Messware code in Perl. The one thing I can't help you on is why and when {braces} are needed. The only Excel use I have found is in $app->{Visible} = 1. Watch out, though, for case. Perl is case sensitive while VBA isn't - it will convert case for you, and whatever it gives you is what you should use.


    John Davies
Re: Where is the Win32::OLE Docs
by Gangabass (Vicar) on Oct 09, 2009 at 08:41 UTC

    Just start your Word, press Alt+F11 and select Object Browser (press F2). After that you can find what properties and methods have Word objects.

Re: Where is the Win32::OLE Docs
by wfsp (Abbot) on Oct 09, 2009 at 09:23 UTC
    Record a macro in Word and look at the code generated. It can be verbose but often gives a clue as to what is needed.
Re: Where is the Win32::OLE Docs
by Burak (Chaplain) on Oct 10, 2009 at 22:26 UTC
    Win32::OLE is an API to access OLE/COM Servers. Word is an OLE Server and it has an Object Model defined in it's documents or in the macro suite as mentioned in Re: Where is the Win32::OLE Docs. The properties/methods and the types of arguments to pass to them are defined in the Object Model. Grab a copy of Win32 Perl Programming: The Standard Extensions (2nd Edition) for a gentle introduction to OLE Automation. It's old but still valid. It will not help you to write MSWord controllers but will help you to understand how it works and summarizes the core concepts.
Re: Where is the Win32::OLE Docs
by Anonymous Monk on Oct 09, 2009 at 08:53 UTC

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2021-02-25 05:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found