There is no need for a module, as you can use the OLE interface to interact directly with Word. Any module that wraps (or replaces) this functionality would have to be updated for each new version of Office that comes out.

This code should get you started on the right track (though this is written for Word 2013, as that is what I have. You should be able to just change the object library version number to get it to work with your version of Word

use 5.16.2; use Win32::OLE; use Win32::OLE::Const 'Microsoft Office 15.0 Object Library'; my $word = Win32::OLE->new( 'Word.Application', 'Quit' ); my $doc = $word->Documents->Open( 'C:\Temp\OLE\Word\test.docx' ) || d +ie 'Unable to open document: ', Win32::OLE->LastError; my $paragraphs = Win32::OLE::Enum->new( $doc->Paragraphs ); while ( defined( my $paragraph = $paragraphs->Next ) ) { my $words = Win32::OLE::Enum->new( $paragraph->{Range}->{Words} ); while ( defined( my $word = $words->Next ) ) { $word->{Text} =~ s/([Hh])i/$1ello/; } } $doc->Save; $doc->Close;

You may also find this helpful: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word%28v=office.14%29.aspx


In reply to Re: To Read and Edit docx files in Windows 7 by SimonPratt
in thread To Read and Edit docx files in Windows 7 by DVCHAL

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.