I am using the following to retrieve the text from cell(5, 2)
ActiveDocument.Tables.Item(1).Cell(5,2).Range.Text
It is coming back with the text but with extra characters appended.
When the cell is blank it is coming back with three characters. I
presume this is partly the carriage return and linefeed, how can I
eliminate these?
Nirmal
Greg - 07 Apr 2006 16:47 GMT
Nirmal,
There are a couple of ways to strip the cell marker. Here is one:
Sub ScratchMacro()
Dim oTbl As Table
Set oTbl = ActiveDocument.Tables(1)
With oTbl
MsgBox Left(.Cell(5, 2).Range.Text, Len(.Cell(5, 2).Range.Text) - 2)
End With
End Sub
Nirmal Singh - 07 Apr 2006 16:58 GMT
>There are a couple of ways to strip the cell marker. Here is one:
>
[quoted text clipped - 5 lines]
>End With
>End Sub
Greg,
Thanks for that, I was just wondering if there was anything built into
Word to ignore these cell markers?
Nirmal
Martin - 07 Apr 2006 18:30 GMT
This ain't elegant but works (you may need to fiddle the number at the end):
Left(ActiveDocument.Tables.Item(1).Cell(5, 2).Range.Text, _
Len(ActiveDocument.Tables.Item(1).Cell(5, 2).Range.Text) - 2)
> I am using the following to retrieve the text from cell(5, 2)
>
[quoted text clipped - 6 lines]
>
> Nirmal
Doug Robbins - Word MVP - 09 Apr 2006 16:00 GMT
Dim myrange as Range
Set myrange = ActiveDocument.Tables(1).Cell(5,2).Range
myrange.End = myrange.End - 1
myrange will now contain just the text from the cell without the end-of-cell
marker.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I am using the following to retrieve the text from cell(5, 2)
>
[quoted text clipped - 6 lines]
>
> Nirmal