Thread: [Solved] Save Selection
View Single Post
 
Old 01-12-2011, 06:18 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,383
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,

Your reference in previous posts to fields and forms led me to believe you were working with formfields.

Nonetheless, the same principles apply:
Code:
Sub Demo()
Dim strTmp As String
With ActiveDocument
  strTmp = .ContentControls(1).Range.Text
  strTmp = strTmp & ":" & .ContentControls(2).Range.Text
  strTmp = strTmp & ":" & .ContentControls(3).Range.Text
  .Indexes.MarkEntry Range:=.Bookmarks("IndexThis").Range, _
    Entry:=strTmp, CrossReference:="", CrossReferenceAutoText:="", _
    BookmarkName:="", Bold:=False, Italic:=False
End With
End Sub
If you were to bookmark the controls, you could retrieve the text via the bookmarks:
Code:
Sub Demo()
Dim strTmp As String
With ActiveDocument
  strTmp = .Bookmarks("BkMk1").Range.ContentControls(1).Range.Text
  strTmp = strTmp & ":" & .Bookmarks("BkMk2").Range.ContentControls(1).Range.Text
  strTmp = strTmp & ":" & .Bookmarks("BkMk3").Range.ContentControls(1).Range.Text
  .Indexes.MarkEntry Range:=.Bookmarks("IndexThis").Range, _
    Entry:=strTmp, CrossReference:="", CrossReferenceAutoText:="", _
    BookmarkName:="", Bold:=False, Italic:=False
End With
End Sub
Note how the bookmarks change, but we're always referring to the first content control within the bookmarked range.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote