D
david.f.jenkins
I have written a SUB that receives a textrange as an argument. In the
SUB, I replace some of the text in the textrange. Before I make the
replacement in the SUB, I extend the length of the textrange an
appropriate number of characters by using the InsertAfter method.
After I do the InsertAfter, the Length property appears to have been
adjusted.
I then do a Replace. If the replacing text is longer than the replaced
text, the TextRange appears to get arbitrarily reset to all of the text
in the enclosing shape. (The textrange in question is selected text in
that shape.) And yet a debug view of the argument in the call to the
SUB shows a textrange with the original length at the time of the call,
but with the changed text. As far as the calling routine is concerned,
the text has been changed, but the length has not.
How can that be?
I'm calling by Ref, BTW. If I change the textrange with the Replace
and InsertAfter methods, shouldn't it be changed when I return to the
calling routine? Am I misundertanding how the object references are
being resolved?
I just want to insert text in a textrange, and have the length of the
range get adjusted accordingly. It's been a year or so that I've been
toying with this problem off and on -- if it's impossible to do, just
tell me, so that I can get on with my life!
SUB, I replace some of the text in the textrange. Before I make the
replacement in the SUB, I extend the length of the textrange an
appropriate number of characters by using the InsertAfter method.
After I do the InsertAfter, the Length property appears to have been
adjusted.
I then do a Replace. If the replacing text is longer than the replaced
text, the TextRange appears to get arbitrarily reset to all of the text
in the enclosing shape. (The textrange in question is selected text in
that shape.) And yet a debug view of the argument in the call to the
SUB shows a textrange with the original length at the time of the call,
but with the changed text. As far as the calling routine is concerned,
the text has been changed, but the length has not.
How can that be?
I'm calling by Ref, BTW. If I change the textrange with the Replace
and InsertAfter methods, shouldn't it be changed when I return to the
calling routine? Am I misundertanding how the object references are
being resolved?
I just want to insert text in a textrange, and have the length of the
range get adjusted accordingly. It's been a year or so that I've been
toying with this problem off and on -- if it's impossible to do, just
tell me, so that I can get on with my life!