Determining where I am in ThisDocument_SelectionChange

Hi,

I'm trying to determine where I am in the document within the ThisDocument_SelectionChange event. I have a document with XML tags in it, and would like to select which ActionPane Control I show based on which XML tag I am in. I thought that e.Selection.Range.XMLNodes(0) or something might do the trick, but it appears that the e.Selection.Range.XMLNodes collection is empty.

Anyone know what I am doing wrong, or if there is another way to achieve this

Thanks.

Aaron.


Answer this question

Determining where I am in ThisDocument_SelectionChange

  • Charles Gray

    Hi,

    About 5 minutes after posting this question, I figured it out. Can't believe, a) how simple it is, and b) how I missed it!

    All the XML nodes that are in the document are accessible as objects, which you can see (unless visually challenged like myself) in the left-hand dropdown at the top of the code window in thisdocument.vb. They all have Select events so you can easily add code to fire on the selection of a tag.





  • caprio

    I am not sure whether you have seen those or not but check out the video tutorials section on vsto2 blog here http://blogs.msdn.com/vsto2/archive/category/9754.aspx

    Those sometimes have glimpses of very useful information.

  • rooz

    Even better that that, you can use the _ContextEnter and _ContextLeave events for when the user enters and exits from a node. Nice! :-)

  • theManMyth

    Misha,

    Just had a nosey at the site. Looks pretty good. Will have to spend some time going through the webcast. Strangely enough, there is one there that answered my question! Or, did you already know that... ;-)

    Thanks.

    Aaron.

  • Determining where I am in ThisDocument_SelectionChange