Jan 21, 2011, 7:26 AM
Post #1 of 1
I like to make this thread the ultimate win32::OLE thread....
Win32::OLE ms word read write object table properties
to ask questions about reading/writing about ms word and excel and other OLE objects in Perl. These objects could be table, paragraph, diagram, etc. and you want to be able to read, write, read the paragraph or line above, below, select a particular text, copy, paste, etc.
Which libraries to use?
well, for my first task I wanted to be able to open word documents in a folder and read one table by row and column.
Now , after searching through the net I found bunch of libraries people include, a couple of them appears all the time but some of them vary depending on the program people use:
# we are going be working with MS Word Objects
use Win32::OLE qw(in with); # used a lot
# sometimes uses
use Win32::OLE::Const 'Microsoft Word';
Not sure exactly what the last two libraries do? can someone show me step by step by step how do I look it up in CPAN?
Finally, the part I am really stuck in my program is however, being able to see all the methods and properties of an object which I get hold off:
e.g. # get the first table
my $table = $word->ActiveDocument->Tables(1);
How do I now list this table's methods and properties...how would I know what they are? Where are these documented? Win32::OLE is a bit dry and very example-free.
Another side question: when I open documents, can I supply relative path? I can only open now using absolute path:
e.g. $Word->Documents->Open("$doc") || die("Unable to open $doc ", Win32::OLE->LastError());
$doc cannot be "..\\FOLDER\\FOLDER\\DOC.DOC
it has to be "C:\\FOLDER\\FOLDER\\FOLDER\\DOC.DOC"
can I make it relative?