0x0D 0x07 counted as one?

W

Wallentin

HI!

I have created an application that interacts with Word documents through the
Window, Document, Range and Selection COM interfaces. It’s a C++ application
but I hope you VBA folks can help me with a minor problem :)

My application was working very well until I encountered the strange 0x0D
0x07 (chr(13)chr(7)) combination used in tables.

The problem is not the control codes themselves. I ignore control codes
anyway. The problem is that the combination of these two codes is only
counted as one in the character count returned by the COM interfaces, but
they are returned as two!?

I’ll try to explain my problem through some pseudo code:

numCharsInDoc = Document.Range.End

caretPosition = Window.Selection.End

allText = Document.Range.Text

I an ordinary Word document the number of characters in my text buffer
(allText) would equal the returned character count (numCharsInDoc), and I
would be able to use the caret offset (caretPosition) as a pointer into my
buffer.

In a Word document with one or more tables, the number of characters in the
text buffer (allText) will be greater than the returned character count
(numCharsInDoc). In the numCharsInDoc (and in the caretPosition) variable the
0x0D 0x07 combination is counted as one but they are returned as two in the
text buffer. Given these circumstances I have no clue as to where my caret
offset is pointing…

-Is this a correct conclusion of what is happening?
-Would it be possible to some how get the correct character count?
-Are there any other special control code combinations that I ought to
know about?

I hope someone can help me on this. Any suggestions are more than welcome or
if someone have a link to some documentation on this subject…

Thanks in advance.

W.
 

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