By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,083 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,083 IT Pros & Developers. It's quick & easy.

To compare two word docs and make changes in one to make it same as first one?

P: 11
I want to write a generic function to compare two word documents and make changes in one so as to make it same as the another one.

Also, I want to do the same with two text files.
Apr 25 '07 #1
Share this Question
Share on Google+
2 Replies

P: 11
I have a code which returns whether the two documents are same or not:
Expand|Select|Wrap|Line Numbers
  1. Function fnCompWordDocs(strPathA, strPathB)
  4. Set objWord = CreateObject("Word.Application")
  5. Set A = objWord.Documents.Open(strPathA)
  6. Set B = objWord.Documents.Open(strPathB)
  7. MsgBox A.Content.Text
  8. MsgBox B.Content.Text
  9. If A.Content.Text = B.Content.Text Then
  10.    fnCompWordDocs = "Documents are same"
  11. Else
  12.    fnCompWordDocs = "Documents are not same"
  13. End If
  14. A.Close
  15. B.Close
  16. objWord.Visible = False
  17. Set objWord = Nothing
There's a also a code which identifies differences in two word documents:
Expand|Select|Wrap|Line Numbers
  1. Function fnOverWriteDocs(strPathA, strPathB)
  3. Set objWord = CreateObject("Word.Application")
  4. Set A = objWord.Documents.Open(strPathA)
  6. MsgBox A.Content.Text
  8. objWord.ActiveDocument.Compare strPathB
  9. End Function
But I dont know how to save the changes identified at the end of comparison.
Please suggest.
Apr 25 '07 #2

Expert 5K+
P: 8,434
If you want to change doc B to match doc A, what's wrong with the simple approach...
  • Select all of doc A
  • Copy
  • Select all of doc B
  • Paste
Apr 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.