Publisher PIA change of behavior for TextRange.Text between Office 2003 and 2007
- I have a .Net-based COM add-in that works in Publisher in which I go thru the "Stories" one-by-one and change the encoding of words (also, one-by-one) in-situ.
I iterate the Paragraphs in a Story and for each Paragraph, I use a TextRange object to isolate a single word (and it's following space) to do
the replacement. So, for example, if I had a Paragraph that contained:
// aTextRange.Text == "This is a paragraph\r";
Then I would make a working copy of that TextRange and set the Start = 0 (the beginning of the range) and the End = 5 (the offset of the 'i' in 'is') and this would result in:
// myTextRange.Text == "This "
Then I select that range (i.e. myTextRange.Select()) and then set the ".Text" property to my new encoding of that word (e.g. for Piglatin,
"myTextRange.Text = "Isthay ").
Now the problem: in Office 2003, even though my replacement text is longer, it only replaces the selected portion of the original range (resulting in the original range becoming "Isthay is a paragraph\r"), which is what I want.
But in Office 2007, it seems to ignore what portion of the TextRange is selected and replaces the length of the new string (resulting in the
original range becoming "Isthay paragraph"--I.e. clobbering the next word(s), because the replacement string is longer than the original word).
Is there some way to work around this? That is, I know that I can use the _Application.Version to detect whether I'm talking to Publisher 2003 or 2007 and treat them differently, but I'm not sure how to work with the TextRange object in 2007 to make it behave like the 2003 PIA does.
Any ideas?
Thanks,
Bob
P.S. This is only a problem with the Publisher PIAs. I do the same thing in Excel, Access, and Word (of course, with the RangeText object, instead), and it works the same in both the 2003 and 2007 versions.
Answers
Hello Bob,
This forum provides support for documentation and interoperability questions on open specifications.
The Open Protocol Specifications can be found at: http://msdn2.microsoft.com/en-us/library/cc203350.aspx.
Your post does not appear to be related to the Open Protocols Specifications documentation set.
I think a better forum for you question may be: http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.publisher.programming&lang=en&cr=US. It looks like you have posted there as well and that is definitely where I would start.
Thanks
John Dunning
Senior Escalation Engineer Microsoft Corporation
US-CSS DSC PROTOCOL TEAM- Marked As Answer byAlex MorrillMSFT, ModeratorWednesday, July 15, 2009 7:37 PM
All Replies
Hello Bob,
This forum provides support for documentation and interoperability questions on open specifications.
The Open Protocol Specifications can be found at: http://msdn2.microsoft.com/en-us/library/cc203350.aspx.
Your post does not appear to be related to the Open Protocols Specifications documentation set.
I think a better forum for you question may be: http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.publisher.programming&lang=en&cr=US. It looks like you have posted there as well and that is definitely where I would start.
Thanks
John Dunning
Senior Escalation Engineer Microsoft Corporation
US-CSS DSC PROTOCOL TEAM- Marked As Answer byAlex MorrillMSFT, ModeratorWednesday, July 15, 2009 7:37 PM


