Selecting text in cell for hyperlink

B

Bob

I have a table in which the text of the first cell of each
row is to be hyperlinked.

I am having problems selecting the text in the cell.
Originally the whole cell was being selected, so I decided
to add the collapse method. It is successful in that it
actually selects text.

For i = 1 To ActiveDocument.Tables(1).Rows.count
With ActiveDocument.Tables(1).Cell(i, 1).Range
.Select
Selection.Collapse wdCollapseStart
Selection.Expand wdSentence - 1

ActiveDocument.Hyperlinks.Add
Anchor:=Selection.Range, _
Address:="http://. . . "
End With
Next istep

However, it doesn't select all the text in the cell. The
code shown above only selects the first word. If I try

Selection.Expand wdSentence

I get the whole cell. I've tried other wdunits without
success. Any suggestions?
 
H

Helmut Weber

Hi Bob,
how about this:
Dim rCll As Range
Dim i As Integer
For i = 1 To ActiveDocument.Tables(1).Rows.Count
With ActiveDocument.Tables(1).Cell(i, 1)
Set rCll = .Range
rCll.End = rCll.End - 1
rCll.Select
' hyperlink etc.
End With
Next
Greetings from Bavaria, Germany
Helmut Weber
"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