Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

comparing two TOCs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BorisS - 29 Jun 2005 16:36 GMT
Okay, I have two tables of contents in two separate files.  A few of the
entries in them may be repeats (each is updated regularly, and each will
have different entries each time, with possible different overlaps each time).
I need to, from one of the files, run a macro that will look through every
entry of that file's TOC, then compare each to the TOC of the other file
(preference would be a dialogue way to point to the other file to use, but
could also type into a dialogue, and worst case, can go into the macro and
type in the path for each use...but would prefer to avoid having to go into
macros, as others might be asked to use this who are less proficient), and
finally highlight on the original file any that are found in the other file.  
Matches would be exact matches for the entire string except page numbers on
each file would be different.

Thx for any code assistance someone may have.

Signature

Boris

Doug Robbins - 29 Jun 2005 21:12 GMT
Something like this might do it (probably needs a bit of refinement - like
deleting all of the page numbers)

Dim Source1 As Document, source2 As Document, target1 As Document, target2
As Document
Set Source1 = ActiveDocument
Set target1 = Documents.Add
Source1.TablesOfContents(1).Range.Fields.Unlink
target1.Range = Source1.TablesOfContents(1).Range
target1.SaveAs "target1.doc"
target1.Close
Source1.Close wdDoNotSaveChanges
With Dialogs(wdDialogFileOpen)
.Show
End With
Set source2 = ActiveDocument
Set target2 = Documents.Add
source2.TablesOfContents(1).Range.Fields.Unlink
target2.Range = source2.TablesOfContents(1).Range
source2.Close wdDoNotSaveChanges
target2.Compare Name:="target1.doc", _
       CompareTarget:=wdCompareTargetNew

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Okay, I have two tables of contents in two separate files.  A few of the
> entries in them may be repeats (each is updated regularly, and each will
[quoted text clipped - 14 lines]
>
> Thx for any code assistance someone may have.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.