Finding parent TextBox RRS feed

  • Question

  • hi,

    I have a table inside a textbox. The selection is inside the table. I would like to, based on this, get my TextBox shape.

    Getting the table was easy enough, since i could just access Selection.Tables[1], but i can't seem to find the textbox shape anyway.

    How do i do this?

    Nicolai Søndergaard - LM Wind Power A/S
    Tuesday, November 30, 2010 2:45 PM

All replies

  • Which application? And which version of that application?
    Cindy Meister, VSTO/Word MVP
    Wednesday, December 1, 2010 11:06 AM
  • Sorry Cindy, i was certain i had written it. Silly me..

    Word 2007.


    Right now, i cycle through all shapes in the document, see if my table is in its textrange, and then find it that way.

    However, there's a potential for ALOT of shapes in these documents, so i was hoping for a more direct way.

    Nicolai Søndergaard - LM Wind Power A/S
    Wednesday, December 1, 2010 2:32 PM
  • Hi Nicoolai

    Mmm, I can't find any way to do it, other than the one you've already found.

    Best I can suggest would be to cycle through the document once. Assign names to the Shapes (or just the Textboxes) and insert a bookmark around the TextRange content. Keep a List of these Name/Bookmark pairs. You should be able to get the bookmark easily enough, then match the Shape name to it (which is an Index value of the Shapes collection).

    I'm going to move this to the Word Developer forum, as someone there might have another idea how this could be done. I get the feeling I'm missing something...

    Cindy Meister, VSTO/Word MVP
    Thursday, December 2, 2010 8:28 AM