How to compare Word documents in UFT?
Question ID: 106673
1
0

I need to compare 2 Word documents to see if there are any changes from the original. Can UFT do this?

Marked as spam
Posted by (Questions: 387, Answers: 66)
Asked on January 29, 2016 11:07 pm
170 views
Answers (1)
1
Private answer

You can do this using the VBScript below. Doc Original.docx would be the original. Doc NoChanges.docx would be a document that matches doc A. Doc Changes.docx would be a doc that has changes from A.

Please note that Word has to be installed on the machine for this to work.

MyDoc1= ''C:MyDocsOriginal.docx''
MyDoc2= ''C:MyDocsNoChanges.docx'' 'no changes from Original.docx
'MyDoc2= ''C:MyDocsChanges.docx'' 'changes from Original.docx

set objWord = createobject(''Word.Application'')
objWord.Visible =true

Set oMyDoc1=objWord.Documents.Open(MyDoc1)
Set oMyDoc2=objWord.Documents.Open(MyDoc2)

Set Dcomp=objWord.CompareDocuments(oMyDoc1,oMyDoc2)

intChangeCount= Dcomp.Revisions.count

If intChangeCount <> 0 Then
'Some changes are detected
MsgBox ''There are changes''
Else
MsgBox ''There are no changes''
End If
oMyDoc1.Close
oMyDoc2.Close
Dcomp.Close false
objWord.Quit false
Set objWord=nothing

Marked as spam
Posted by (Questions: 17, Answers: 807)
Answered on January 29, 2016 11:08 pm
0
Very helpful information, thanks!
( at January 29, 2016 11:09 pm)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top