Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Special Character at End of Each Table Cell

1,178 views
Skip to first unread message

CoxProg

unread,
Jan 13, 2012, 5:39:45 PM1/13/12
to

I am trying to test the contents of cells in a table. However, the
special character found in each table cell throws me off. I have some
options of getting around it (described below), but are there any other
suggestions on how to work around this?

Here is my simplified code:

Dim TextToTest As String

TextToTest = ActiveDocument.Tables(1).Cell(Row:=1,
Column:=1).Range.Text

If TextToTest = "Sought Value" Then
MsgBox "True"
Else
MsgBox "False"
End If

My result is always "False." When I look at the extracted value of
TextToTest on a cell that contains "Sought Value", I get:

Sought Value
(the next line contains a bullet looking thing that this window will not
let me paste into it)

That pesky character! :) I have rigged some ways around it by
calculating the length of the TextToTest (x) and then extracting x-2
characters from the left.

But I am looking for an option that references that special character
directly. Different threads suggest the special character is "^10" or
"^008" but my tests for those characters didn't seem to work.

Thanks in advance!





--
CoxProg

Suzanne S. Barnhill

unread,
Jan 13, 2012, 10:21:39 PM1/13/12
to
The character is the end-of-cell mark, which holds the formatting for the
cell and also functions for the paragraph mark for the last (or only)
paragraph in a cell. Word doesn't, apparently, provide any way to address it
directly.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"CoxProg" <laelcox...@hotmail.com> wrote in message
news:CoxProg...@wordbanter.com...

Stefan Blom

unread,
Jan 14, 2012, 10:06:28 AM1/14/12
to
As Suzanne wrote, I don't think there is a way to work with the end-of-cell
mark directly. I'm not even sure it would be useful, if it was possible. As
you have noticed, a workaround is required.

You have been removing the final character of the string. The alternative is
to work with a range object from which you remove the final character (by
redefining the range). For example:

Sub MyTestSub()
Dim r As Range
Set r = ActiveDocument.Tables(1).Cell(1, 1).Range.Duplicate
If r.End > r.Start Then
r.End = r.End - 1

End If

' more code follows...
End Sub

--
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"CoxProg" wrote in message news:CoxProg...@wordbanter.com...
0 new messages