read string from table

M

Mark

I'm trying to find a specific table in a Word 2002 document by reading the
string in its first cell and comparing it to a fixed string. The code looks
like this:

Dim myTest as string
Dim myTable as Table

For tableNo = 1 To totalTables
Set myTable = ActiveDocument.Tables(tableNo)
myTest = myTable.Cell(1, 1).Range.Text
If myTest = "SomeUniqueWord" Then
blah, blah

The problem is that myTest contains the text from the table plus a couple of
strange characters at the end that show up as rectangles on my screen.
Nothing I have tried seems to get rid of those funny characters or allow me
to make a match on it. I've tried trim(), as well as other string cleaner
functions and I've tried StrComp() too. Either it won't match or I get a
type mismatch.

Is there some way to get just the visible characters from the cell?
Thanks, Mark
 
C

Chad DeMeyer

Mark,

These characters are codes that translate into the end-of-cell marker. They
will ALWAYS be present in a table cell, so you can change your code as
follows:

myTest = myTable.Cell(1,1).Range.Text
myTest = Left(myTest, Len(myTest) - 2)

cjd
 

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