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 / Mailmerge and Fax / June 2004

Tip: Looking for answers? Try searching our database.

Table of Contents and Cross Referencing (variables) Help!!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fvta - 15 Jun 2004 23:02 GMT
Hello-

I am having trouble with two items in my Main Document during my post merger operation - the Table of Contents and Cross Referencing insertions.

When I have a Table of Contents in the Main Document and merge to a new document, the new merged document converts the entire TOC to hyperlinks.  This only started after I upgraded to Office 2002 (I was using 2000 previously).  I cannot figure out how to undo this feature or reverse this process.  

Second, Cross References in my Main Document go hard and simply do not cross reference in the new merged document.  Is there a way to preserve the cross references or is this impossible?

Thank you in advance!!
Cindy M  -WordMVP- - 16 Jun 2004 18:05 GMT
Hi =?Utf-8?B?ZnZ0YQ==?=,

> I am having trouble with two items in my Main Document during my post merger operation - the Table of Contents and Cross Referencing insertions.
>  
> When I have a Table of Contents in the Main Document and merge to a new document, the new merged document converts the entire TOC to hyperlinks.  This only started after I
upgraded to Office 2002 (I was using 2000 previously).  I cannot figure out how to undo
this feature or reverse this process.  
>  
Try this: In the main merge document press Alt+F9 to see the TOC field code. Delete the \h
swtich. Alt+F9 again

> Second, Cross References in my Main Document go hard and simply do not cross reference in the new merged document.  Is there a way to preserve the cross references or is this
impossible?

I'm afraid you're out of luck with this one. Cross-references rely on bookmarks. Bookmark
names must be unique in a document. Since mail merge would duplicate bookmark names, they
are simply removed during the mail merge process.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :-)
Fvta - 16 Jun 2004 20:39 GMT
Deleting the \h switch doesn't work.  Any other ideas??

> Hi =?Utf-8?B?ZnZ0YQ==?=,
>
[quoted text clipped - 24 lines]
> This reply is posted in the Newsgroup; please post any follow question or reply in the
> newsgroup and not by e-mail :-)
Cindy M  -WordMVP- - 17 Jun 2004 15:39 GMT
Hi =?Utf-8?B?RnZ0YQ==?=,

> Deleting the \h switch doesn't work.  Any other ideas??
>  
Could you please be more specific by what you mean with "coverts the entire TOC to hyperlinks"?
If you click, do you jump to the place in the document?

Or is this just a question of formatting?

If you press Alt+F9 do you even see a TOC field?

FWIW, a TOC also bases on bookmarks, which probably aren't available anymore in the document.
It could be that you're just seeing "hyperlink" font formatting (blue and underline) on plain
text.
 
> > > I am having trouble with two items in my Main Document during my post merger operation -
> > the Table of Contents and Cross Referencing insertions.
[quoted text clipped - 6 lines]
> > Try this: In the main merge document press Alt+F9 to see the TOC field code. Delete the \h
> > swtich. Alt+F9 again

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :-)
fvta - 17 Jun 2004 19:32 GMT
The table of contents is no longer shaded or is not "hot", meaning it won't jump to the place in document if click a particular title.  It just takes you to the beginning of the document.  

Yes it is highlighted like a www hyperlink.  When I used Word 2000, I was not having this problem.  

> Hi =?Utf-8?B?RnZ0YQ==?=,
>
[quoted text clipped - 29 lines]
> This reply is posted in the Newsgroup; please post any follow question or reply in the
> newsgroup and not by e-mail :-)
fvta - 17 Jun 2004 20:31 GMT
Cindy,

Doug Robbings posted this in an effort to help a member in regards to retaining bookmarks in a merged document.  I was wondering if this macro could be applied to solve my problem also:

If you run the following macro when the mailmerge main document is active,
it will execute the merge to a new document, split that new document into
individual documents with each document corresponding to a record in the
datasource and then it will recreate the bookmarks that were in the main
document in each of those documents and save and close them with a filename
"Letter#" where # is a sequential number:

' Throwaway Macro created by Doug Robbins to "preserve" bookmarks during a
mailmerge
'
Dim abm As Bookmark, bmrange As Range, i As Long, Result As Document, j As
Long, k As Long
Dim Target As Document, Letter As Range, source As Document
Set source = ActiveDocument
i = 1
For Each abm In ActiveDocument.Range.Bookmarks
   System.PrivateProfileString("c:\bookmarks.txt", "bookmarkNames",
"bookmark" & i) = abm.Name
   abm.Range.InsertBefore "#"
   abm.Range.InsertAfter "#"
   i = i + 1
Next
With ActiveDocument.MailMerge
   .Destination = wdSendToNewDocument
   .Execute
End With
Set Result = ActiveDocument
For j = 1 To Result.Sections.Count - 1
   Set Letter = Result.Sections(j).Range
   Letter.End = Letter.End - 1
   Set Target = Documents.Add
   Target.Range = Letter
   k = 1
   Selection.HomeKey wdStory
   Selection.Find.ClearFormatting
   With Selection.Find
       Do While .Execute(FindText:="#*#", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
           Set bmrange = Selection.Range
           bmrange.Characters(bmrange.Characters.Count).Delete
           bmrange.Characters(1).Delete
           Target.Bookmarks.Add
System.PrivateProfileString("c:\bookmarks.txt", "bookmarkNames", "bookmark"
& k), bmrange
           k = k + 1
       Loop
   End With
   Target.SaveAs FileName:="Letter" & j
   Target.Close
Next j
source.Activate
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
   Do While .Execute(FindText:="#*#", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
       Set bmrange = Selection.Range
       bmrange.Characters(bmrange.Characters.Count).Delete
       bmrange.Characters(1).Delete
   Loop
End With

> The table of contents is no longer shaded or is not "hot", meaning it won't jump to the place in document if click a particular title.  It just takes you to the beginning of the document.  
>
[quoted text clipped - 33 lines]
> > This reply is posted in the Newsgroup; please post any follow question or reply in the
> > newsgroup and not by e-mail :-)
Cindy M  -WordMVP- - 18 Jun 2004 17:47 GMT
Hi =?Utf-8?B?ZnZ0YQ==?=,

if you want to go this route, then I recommend Peter Jamieson's approach, instead, that
basically flips through each record, sending that to the printer. Then you don't have to
recreate the bookmarks at all. (See below my sig)

However, I don't think this would help with the TOC problem, if you want a TOC for each
merge record? Mail merge also unlinks most field codes (turns them to plain text), so
you'd have the additional problem of recreating the TOC.

What, more exactly, are you trying to accomplish with the mail merge? You might be better
off to simply do the whole thing using VBA...

> Doug Robbings posted this in an effort to help a member in regards to retaining bookmarks in a merged document.  I was wondering if this macro could be applied to solve
my problem also:
>  
> "If you run the following macro when the mailmerge main document is active,
[quoted text clipped - 3 lines]
> document in each of those documents and save and close them with a filename
> "Letter#" where # is a sequential number:"

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :-)

Sub ProduceOneDocPerSourceRec()
'

' NB, needs bettor error management and doubtless other things a VBA expert ' will point
out.

Dim intSourceRecord
Dim objMerge As Word.MailMerge
Dim strOutputDocumentName As String
Dim TerminateMerge As Boolean

' Need to set up this object as the ActiveDocument changes when the ' merge is performed.
Besides, it's clearer.

Set objMerge = ActiveDocument.MailMerge
With objMerge

' If no data source has been defined, do it here using OpenDataSource.
' But if it is already defined in the document, you should not need to define it here.

'  .OpenDataSource _
'    Name:="whatever"

 intSourceRecord = 1
 TerminateMerge = False

 Do Until TerminateMerge
   .DataSource.ActiveRecord = intSourceRecord

   ' if we have gone past the end (and possibly, if there are no records)
   ' then the Activerecord will not be what we have just tried to set it to

   If .DataSource.ActiveRecord <> intSourceRecord Then
     TerminateMerge = True
   ' the record exists
   Else

    ' while we are looking at the correct activerecord,
     ' create the document path name
     ' e.g.
     strOutputDocumentName = _
       "c:\Training\course details_" & _
       .DataSource.Datafields("Employee_no").Value & _
       ".doc"

     .DataSource.FirstRecord = intSourceRecord
     .DataSource.LastRecord = intSourceRecord
     .Destination = wdSendToNewDocument
     .Execute

     ' The Activedocument is always the output document
     ' Add any parameters you need to these calls
     ActiveDocument.SaveAs strOutputDocumentName
     ActiveDocument.Close
     intSourceRecord = intSourceRecord + 1
   End If
 Loop
End With
End Sub
 
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.