This function calls the native vbCompare() function in M$ Word and writes the output to a new Word doc. It dies on errors so wrap in an eval if you care.
sub CompareWord { my( $doc1, $doc2, $outfile) = @_; require Win32::OLE; $Win32::OLE::Warn = 3; # die on errors... my $Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit'); my $WordFile = $Word->Documents->Open($doc1); $Word->{Visible} = 0; $WordFile->Compare( $doc2 ); $Word->WordBasic->FileSaveAs( $outfile); $WordFile->Close(); undef $WordFile; undef $Word; }

Replies are listed 'Best First'.
Re: Compare two Microsoft Word Documents
by StrifeChild (Novice) on Aug 02, 2004 at 01:28 UTC
    Why not just have an MD5 checksum for each file and compare the two? This has less overhead and will work on all files, not just Microsoft Word documents.

      That is a bit like saying what is the use of diff(1) when you can just use checksums. Checksums only indicate change, they do not quantify it.

      cheers

      tachyon