473,799 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

11 New Member
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
2 1544
tweety123
11 New Member
I have a code which returns whether the two documents are same or not:
Expand|Select|Wrap|Line Numbers
  1. Function fnCompWordDocs(strPathA, strPathB)
  2.  
  3.  
  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)
  2.  
  3. Set objWord = CreateObject("Word.Application")
  4. Set A = objWord.Documents.Open(strPathA)
  5.  
  6. MsgBox A.Content.Text
  7.  
  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
Killer42
8,435 Recognized Expert Expert
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

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

Similar topics

3
5807
by: jyoti | last post by:
Hi there, I am trying to compare two strings and get the differenc in vbscript. Example: Str1="This is a test text" Str2="This is a fine test text but a little long" I like to compare str1 with str2 and get the difference. Above example the difference will be "fine" and "but a little long" How do I do that? A sample code would be apprciable.
122
5352
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) { /* array differs from value, do something*/
1
615
by: ajk | last post by:
. Hi, All: I know how to insert files into a Word doc using C#. However, the program I've written to do this runs much too slowly. The "myObj".Application.Selection.InsertFile method executes at a snails pace. Here are the detais: I wrote a C# program that creates a new Word doc and then loops through a
2
1943
by: KnotKnormal | last post by:
I would like to dynamically load a HTML page (or a Word document), which is embedded in a table when the user clicks on a hyperlink to go from HTML page one to HTML page two. For example, I would like the secretary at a school to update a Word document concerning homework assignments. This Word document would reside on the server. When changes are made it, these changes are automatically updated to the web page. This would simplify life...
10
1576
by: ljh | last post by:
Google ran dry on me while looking for .Net examples of how to compare 2 Word Docs. Has anyone here seen anything like that?
6
1848
by: Al | last post by:
I'd like to know if there were any changes in the DataSet which was populated by reading XML file. 6 DataTables with data or just structure with no data inside of it. I think about this scenario: I create 2 datasets and populate both from the same XML file. Then the first one is used as DataSource for many controls and the second one is untouched. If there were some changes in the first one, I'd like to know it and would like to compare...
4
3296
by: Jim Andersen | last post by:
Is there anything built into .NET that is good (or rather easy) at comparing ? I have some data (in an array). I make a copy of this array, and the user changes some of the data, or maybe he doesn't. Then he clicks a button and my code runs. So now I want to see if the user made some changes to the data in the array, or if the user just looked at the data.
11
35427
by: inpuarg | last post by:
I have 2 datatables. They are identical. I want to compare them by cell's content. They are all same. But dt1 == dt2 or dt1.GetHashCode() == dt2.GetHashCode() doesn 't work. There are big amount of rows in theese datatables . So i don 't want to enumerate each rows. This is not efficient and unacceptable for my current application.
6
4645
by: Eric Layman | last post by:
Hi, I have fields from textareas. With a click of a button, php is able to grab these fields and by using header(), convert the output to Ms Word doc. But the outcome of the word doc doesn't wrap the text in textarea. the result is one very veyr long string of text which stretch MS word all
0
9543
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.