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![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
My application was working very well until I encountered
the strange 0x0D 0x07 (chr(13)chr(7)) combination in tables.
The problem is not the control codes in 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 variable
numCharsInDoc, and I would be able to use the caretPosition
as a pointer into my buffer.
I a Word document with one or more tables, the number of
characters in the text buffer will be greater than the
returned 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.
-Is this a correct conclusion of what is happening?
-Would it be possible to some how get the correct character
count?
-Would it be safe to transform all 0x0D 0x07 combinations
to a single 0x0D in my buffer?
-If so are there any other special control code
combinations that I ought to know about?
I hope someone can help me on this issue. All suggestions
are more than welcome or if someone have a link to some
documentation on this subject.
Thanks in advance.
W.
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 in tables.
The problem is not the control codes in 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 variable
numCharsInDoc, and I would be able to use the caretPosition
as a pointer into my buffer.
I a Word document with one or more tables, the number of
characters in the text buffer will be greater than the
returned 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.
-Is this a correct conclusion of what is happening?
-Would it be possible to some how get the correct character
count?
-Would it be safe to transform all 0x0D 0x07 combinations
to a single 0x0D in my buffer?
-If so are there any other special control code
combinations that I ought to know about?
I hope someone can help me on this issue. All suggestions
are more than welcome or if someone have a link to some
documentation on this subject.
Thanks in advance.
W.