Discussion:
Testing for the end of a cell character
(too old to reply)
EEvans
2006-03-23 20:49:35 UTC
Permalink
I would like to know how to detect/check for the end of cell marker in a
table. I have a macro that needs to detect that character to stop. I have
tried vbCr, vbCrLf, etc... What is that character or is there a ASCII value
that I can use?

Thanks,

Eric
Jezebel
2006-03-23 22:28:22 UTC
Permalink
chr(7)

For future reference, you can investigate using the ASC() function, eg

For i = 1 to len(Text)
debug.print asc(mid(text,i,1))
Next
Post by EEvans
I would like to know how to detect/check for the end of cell marker in a
table. I have a macro that needs to detect that character to stop. I have
tried vbCr, vbCrLf, etc... What is that character or is there a ASCII value
that I can use?
Thanks,
Eric
Tony Jollans
2006-03-23 23:57:42 UTC
Permalink
This does depend on whether you are looking at Word 'Characters', in which
case the end of cell is a Range, length 2, chr(13) and chr(7), or looking at
the Text string, in which case the last two characters (with a small c) will
be chr(13) and chr(7).

If you are checking the value of the characters rather than the position
within the cell then the former is the correct method - the latter can
occasionally give the wrong result (in unusual circumstances, I'll grant).

--
Enjoy,
Tony
Post by EEvans
I would like to know how to detect/check for the end of cell marker in a
table. I have a macro that needs to detect that character to stop. I have
tried vbCr, vbCrLf, etc... What is that character or is there a ASCII value
that I can use?
Thanks,
Eric
Helmut Weber
2006-03-24 08:54:03 UTC
Permalink
Hi EEvans,
Post by EEvans
detect/check for the end of cell marker
The end-of-cell-mark consists of chr(13) & chr(7).

If the insertion point is right before the end-of-cell-mark
Len(Selection.Text) returns 2.

Asc(Right(Selection.Text, 1)) returns 7.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Continue reading on narkive:
Loading...