Compare two Microsoft Word Documents
tachyon
created: 2004-06-22 00:42:38
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;
}
Re: Compare two Microsoft Word Documents
created: 2004-08-01 21:28:17
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.
Re^2: Compare two Microsoft Word Documents
created: 2004-08-01 22:58:18

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

perlmonks.org content © perlmonks.org and StrifeChild, tachyon

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03