Thread: [Solved] Save Selection
View Single Post
 
Old 01-12-2011, 02:53 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Brock,
Quote:
This creates a three level index based on the values of the three fields.
OK, but if you know the fields' bookmark names, or at least their relative position in the document, you can get the values without and Find/Replace code. For example:
Code:
Sub Demo()
Dim strTmp As String
With ActiveDocument
  strTmp = .FormFields(1).Result
  strTmp = strTmp & ":" & .FormFields(2).Result
  strTmp = strTmp & ":" & .FormFields(3).Result
  .Indexes.MarkEntry Range:=.Bookmarks("IndexThis").Range, _
    Entry:=strTmp, CrossReference:="", CrossReferenceAutoText:="", _
    BookmarkName:="", Bold:=False, Italic:=False
End With
End Sub
If you know the formfield bookmark names, you can replace the 1, 2 & 3 with those. This provides an added level of flexibility. Note too that I haven't had to select anything.

PS: When posting code, please use code tags.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote