B
bwhalversen
Word 2003 sp2, VSTO 2005, C#
I have a need to change the text of the NewXmlNode passed as a paramter to
the application XMLSelectionChange event. My handler:
private void Application_XMLSelectionChange(
Word.Selection Sel,
Word.XMLNode OldXMLNode,
Word.XMLNode NewXMLNode,
ref int Reason)
{
if (NewXMLNode != null)
NewXMLNode.Range.Text = "Some Text"
}
The problem is that this causes a new SelectionChange event to fire that I
can make no sense out of. The new selection Word attempts to set appears to
be completely random. My understanding is that changing the Text propertry of
a Range should not affect the current Selection.
The result is that I get a new XMLSelectionChange event because Word thinks
it left the XMLNode it is currently in (the one whose text I just modified)
because of this "auto-generated" SelectionChange event.
The question may boil down to what can I safely do to the NewXMLNode passed
to the XMLSelectionChange event? Can I change the text of this node in this
event handler? If not, how and when can I make changes to the newly selected
node without causing Word to fire a new (and meaningless) SelectionChange
event?
Thanks for any help you can provide.
I have a need to change the text of the NewXmlNode passed as a paramter to
the application XMLSelectionChange event. My handler:
private void Application_XMLSelectionChange(
Word.Selection Sel,
Word.XMLNode OldXMLNode,
Word.XMLNode NewXMLNode,
ref int Reason)
{
if (NewXMLNode != null)
NewXMLNode.Range.Text = "Some Text"
}
The problem is that this causes a new SelectionChange event to fire that I
can make no sense out of. The new selection Word attempts to set appears to
be completely random. My understanding is that changing the Text propertry of
a Range should not affect the current Selection.
The result is that I get a new XMLSelectionChange event because Word thinks
it left the XMLNode it is currently in (the one whose text I just modified)
because of this "auto-generated" SelectionChange event.
The question may boil down to what can I safely do to the NewXMLNode passed
to the XMLSelectionChange event? Can I change the text of this node in this
event handler? If not, how and when can I make changes to the newly selected
node without causing Word to fire a new (and meaningless) SelectionChange
event?
Thanks for any help you can provide.