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

Hi Monks,

I am using Win32::OLE to access the Word Object. I can able Find the Text/Style and and Replace it.

But, I dont' know that how to get the Table Properties(RowSpan, ColSpan, No of Rows, No of Cols, and Cell Alignment) and Replace it.

use OLE; use Win32::OLE::Const 'Microsoft Word'; my $const=Win32::OLE::Const->Load("Microsoft Word 9.0 Object Library") +; $word=GetObject OLE("Word.Application"); $word->Selection->HomeKey({unit=>$const->{'wdStory'}}); $word->Selection->Find->{'Text'}='<it></it>'; $word->Selection->Find->Replacement->{'Text'}=''; $word->Selection->Find->Execute({Replace=>$const->{'wdReplaceAll'}}); $word->Selection->HomeKey({unit=>$const->{'wdStory'}}); $word->Selection->Find->{'Text'}='<Title>'; $word->Selection->Find->Replacement->{'Text'}=''; $word->Selection->Find->{'Style'}='Normal'; $word->Selection->Find->Replacement->{'Style'}='Title'; $word->Selection->Find->Execute({Replace=>$const->{'wdReplaceAll'}});

Thanks in Advance!!

Replies are listed 'Best First'.
Re: Ms Word Table Properties through Win32::OLE
by jplindstrom (Monsignor) on Mar 07, 2005 at 15:32 UTC
    The best way to figure out how to do something in Word is to record a macro and then look at the generated VBA code.

    Alt-F11 brings up the VBA "console".

    /J