Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

ms-word document comparision

by nicholas (Novice)
on Jun 21, 2004 at 05:54 UTC ( #368373=perlquestion: print w/replies, xml ) Need Help??

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

Hello Experts, I have a tast to compare two ms-word document and save in a new ms-wor +d file. I am using win32::ole. Expert, please give your suggestions. example code will be very helpfu +l. Thanks Nicholas

Replies are listed 'Best First'.
Re: ms-word document comparision
by tachyon (Chancellor) on Jun 21, 2004 at 07:20 UTC

    I would do it by Convert MSWord to Text then use Algorithm::Diff to compare the files a la unix diff(1) command. There is example code in the Algorithm::Diff distro and at Color coded diff. Then output the results to a text file, HTML, PDF, PS, or even another .DOC file as takes your fancy (or the PHBs)



Re: ms-word document comparision
by davidj (Priest) on Jun 21, 2004 at 06:36 UTC
    You really need to be more specific in what you are trying to accomplish before we can help you.

    1) What have you tried so far?
    2) What do you have to compare in the two word documents?
    3) What do you have to save in the new word document?

    This type of information is necessary for us to point you in the right direction.

      Let me detail more here, I wanted to program the simple functionality of ms-word document compa +rision from MS-Word->Tools->Track Changes->Compare documents and I wa +nted to store all new compared content in a new ms-word document. This is only the task which I wanted to make. I have windows server wi +th ActivePerl and win32::ole installed. I think this will help to give right suggestion. Thanks Nicholas
Re: ms-word document comparision
by Zero_Flop (Pilgrim) on Jun 21, 2004 at 18:34 UTC
    Here you go:

    First open the link to the ActiveState documentation. Look up Win32::OLE and check out the example.
    Next open word and hit F11. This opens the VBA window. Hit 'F2' or 'View->Object Browser'. Type in "compare" and read the info on how to call the compare method. Hint the example does exacly what you want to do, saveing to a new file.

    Now write a script in Perl that creates a OLE connection, issues the compare method, and closes.

    If you do not have word installed, then you are going to have to export the data out of word with another application.
Re: ms-word document comparision
by tachyon (Chancellor) on Jun 22, 2004 at 04:43 UTC
      tachyon, Fine, I think it will help. Thanks

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://368373]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2022-07-03 06:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found