Selecting text from table cell

S

Sasa

Hi,
I got this problem. I have figured out how to select one
word (without leading spaces) in table cell but dont know
how to select the whole sentence in table cell but without
the leading spaces.
For example:
I got cell with:[" Hello world "] and I'd
like to select only this "Hello world" text.
What should I do?

Help appreciated.
Regards.

Sasa
 
H

Helmut Weber

Hi Sasa,
let's say, " Hello World " is in cell(1,2):
---
Dim oT As Table ' Table
Dim s1 As String ' string
Set oT = ActiveDocument.Tables(1)
oT.Cell(1, 2).Select ' all of cell
s1 = Selection.Text
s1 = Left(s1, Len(s1) - 2) ' cut off end of cell mark
s1 = Trim(s1) ' cut off leading and trailing spaces
With Selection.Find ' in the selection
.Text = s1 ' for the trimmed string
.Execute
End With
 

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