Select text in cell

J

James Nest

I use this function to get only the text of a cell.


Function Gettext(IntCell As Integer, IntRow As Integer) As String
ThisDocument.Tables(1).Cell(IntCell, IntRow).Select
Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
Gettext = Selection.Text
End Function

It works, but is there a better way ?
 
J

James Nest

in
microsoft.public.word.vba.beginners
Hi James,

I prefer ranges (one of the benefits is that the screen doesn't move
when a user executes the routine).

Function Gettext(IntCell As Integer, IntRow As Integer) As String
Dim oRng As Range
Set oRng = ThisDocument.Tables(1).Cell(IntCell, IntRow).Range
oRng.MoveEnd unit:=wdCharacter, Count:=-1
Gettext = oRng.text
End Function

HTH


Thanks
 

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