|We don't bite newbies here... much|
How do I obtain a list of values for all the properties of a Word document using Win32::OLE?by romandas (Pilgrim)
|on Jun 11, 2009 at 18:02 UTC||Need Help??|
romandas has asked for the
wisdom of the Perl Monks concerning the following question:
This might ramble but bear with me.
Ultimately, I am trying to automate some Word (2003) document editing for our shop using ActiveState Perl 5.10 and Win32::OLE. I haven't done any OLE programming before, so it's slow going. I did read through the excellent tutorial as well as the CPAN Win32::OLE examples (and used some of the example code), but don't see an answer to my question there.
I successfully created a OLE server object and opened the test file (Word document with 'TEST' as the only content). I noticed that my $doc variable is shown as a Win32::OLE=HASH, so I tried to enumerate all the properties (keys) and their values, which is where I ran into trouble. Here's my code so far:
I originally tried to pass $doc to Data::Dumper, but that died with an 'Out of Memory' error. I think that may be related to why my enumeration isn't working any other way I've tried, but I haven't nailed down the root cause.
I then wrote the recursive function you see in my code above, which seems to start enumerating.. but there are several problems with it.
First, it seems to be not just listing values, but executing calls somehow -- as it runs, I get a pop-up to set up Outlook profiles (Outlook isn't setup; this is a development machine), which I have to cancel for it to continue running.
Second, there seems to be a property whose value itself recurses, because I keep getting the same properties over and over after a short period of time. Here is a list of the properties I've seen:
Any ideas where I've gone wrong?