Hi George,
Yes, in the .Text property, you get ^13^7 for end-of-cell-markers and
end-of-row-markers.
Both use only a range of length one.
Other complications are shape anchors and inline shapes (range of length
one, but nothing at all in .Text), and fields (ranges for both the field
code and result, separated by an empty range of length one or two, compared
to only one of them depending on the current view in the .Text).
Tables (especially large ones) are a beast anyway, since anything you do
with them in the Word object model is abysmally slow. So usually, I just
take the .Text and replace ChrW(13) & ChrW(7) with some other character. If
you don't have fields and embedded objects (pictures...), that might be
enough in your case:
str=Replace(str, ChrW(13) & ChrW(7),ChrW(&HE000))
(use anything you like instead of &HE000... which is the first character
from the "End user private use area" in Unicode)
If you have fields and embedded objects:
You can try to build your own text that has the same length and content as
the Range, but it'll be pretty slow if you don't spend a lot of effort.
Say some rather slow code would be:
Dim str As String
Dim rng As Range
Dim i
Set rng = ActiveDocument.Content
str = String(ActiveDocument.Content.End, ChrW(&HFFFD))
' U+FFFD = "replacement character, used to replace incoming characters
' whose values are unknown or unrepresentable in Unicode"
For i = 0 To ActiveDocument.Content.End - 1
Mid(str, i + 1, 1) = ActiveDocument.Range(i, i + 1).Text
Next i
' and to look at that:
Dim DocResult As Document
Set DocResult = Documents.Add
DocResult.Content.InsertAfter str
I've written something that's a lot faster and uses special codes for field
braces, end-of-cell-markers, end-of-row-markers, ..., but it's more than 100
lines of code in two (class) modules. The main idea is to get all the
special problematic ranges into an array (or a collection or dictionary),
and then treat only them and paste the unproblematic .Text between them
unchanged.
Regards,
Klaus