Compare two MS Word Documents with QTP

  • Questions
  • Compare two MS Word Documents with QTP
Question ID: 104747

I am trying to compare two MS Word Documents with QTP. How would you do that?

Marked as spam
Posted by (Questions: 45, Answers: 0)
Asked on December 11, 2012 7:26 pm
Answers (1)
Private answer

I have seen that the compare method has changed depending on version of MS Word you are using. Here is a version of compare that works with my windows 2007.

Dim Doc1, Doc2, oRevs, lrevs
Doc1= ''Z:A.docx''
Doc2= ''Z:c.docx'' 'no changes
'Doc2= ''Z:B.docx'' 'changes
set oWord = createobject(''Word.Application'')
oWord.Visible =true
'set oCompared = oWord.Documents.Open(Doc2)

Set oDoc1=oWord.Documents.Open(Doc1)
Set oDoc2=oWord.Documents.Open(Doc2)

Set Dcomp=oWord.CompareDocuments(oDoc1,oDoc2)

mychangeCnt= Dcomp.Revisions.count

If mychangeCnt <> 0 Then '<--- Not retrieving count property 'Some changes are done MsgBox ''There are Changes '' Else MsgBox ''No Changes'' End If oDoc1.Close oDoc2.Close Dcomp.Close false oWord.Quit false Set oWord=nothing Does this solve you issue?

Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on December 11, 2012 7:32 pm