difference in 'TextRange.Text' between 2003 and 2007 PIAs

B

Bob Eaton

I've created a COM Add-in for Publisher in which I go through a document
word-by-word and after I do some manipulation of each word (basically, an
encoding conversion), I replace it in-situ with the converted value.

I do this by going thru the Paragraphs in the Stories and for each one I get
a running "TextRange" on which I set the Start and End properties to get a
single word. Then I convert its Text property and set it to the converted
value. For example:

// suppose the Story/Paragraph has the text: "This is a sentence."
void foo(Pub.TextRange aParagraphRange)
{
Pub.TextRange aWordRange = aParagraphRange.Duplicate;
aWordRange.Start = 0;
aWordRange.End = 5;
aWordRange.Select();

// at this point, the .Text value is "This "
aWordRange.Text = "That ";

// after setting the aWordRange.Text property, the aParagraphRange...
// in 2003, aParagraphRange.Text == "That is a sentence";
// in 2007, aParagraphRange.Text == "That sentence";
}

That is, this works fine in Publisher 2003. After making such a replacement,
I can requery the paragraph TextRange (which I start with) and the word is
replaced okay ("That is a sentence").

But when I try this in Publisher 2007 (using the v12 PIAs), if I requery the
paragraph TextRange after the replacement, it has the new text in it, but
then it is without the next 5 characters. It's as if setting the .Text
property first clobbers the selected text, and then overwrites the next
chunk with the changed text.

Is there something in the 2007 PIA interface that says "clobber and
overwrite" as the default behavior rather than "replace the selected"?
Something hopefully I can do to fix this?

Thanks,
Bob
 

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