Adding two bookmarks to a cell in a table

  • Thread starter Stephen English
  • Start date
S

Stephen English

I want to add two bookmarks to a cell in a table so that I can then add a
Committee Name to one and a Date to another because I want to retrieve them
later as separate items.
With mytable
.Cell(1, 3).Range.Bookmarks.Add "Ctte"
.Cell(1, 3).Range.Bookmarks.Add "Date"
End With
This just adds both bookmarks to the cell whereas I want it to be
[Committee] [Date]
Any ideas please?
Stephen
 
H

Helmut Weber

Hi Stephen,
how about this one:

Sub Test984()
Dim oRng As Range
Set oRng = ActiveDocument.Tables(1).Cell(1, 1).Range
Resetsearch
With oRng
.Delete
.Text = "Committee Date"
With .Find
.Text = "Committee"
.Execute
End With
.Bookmarks.Add Name:="Ctte"
.Collapse Direction:=wdCollapseEnd
With .Find
.Text = "Date"
.Execute
End With
.Bookmarks.Add Name:="Date"
End With
End Sub

Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top