none
Word 2007 Content control (pick list) to add a row in a table RRS feed

  • Question

  • Sorry if this is old news, but I'm stuck! I've been given this Word document in DOCM format (XML with macros enabled). They have numerous Combo Box content controls inserted all over in tables. What they want is that if someone picks "Yes" or "No" from the list, that it automatically inserts a new row in the table beneath the current row for additional comments.

    I'm brand new to Office 2007 and can't figure out how to make this work!

    Friday, September 16, 2011 11:45 AM

Answers

  • Hi Jim

    The content control exit event is all you've got.

    That, or perhaps linking it to a node in a Custom XML Part, then using the StorageUpdate event. I believe that will trigger on selection.

    Please note that content controls were not designed to be used as "form fields". They're meant to assist in buidling structured documents. According to this design, it's not to be expected that a selection in a content control will change content elsewhere in the document "on change". If you need that kind of behavior, then use a legacy form field, ActiveX control, or a control not on the document surface.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Liliane Teng Friday, September 23, 2011 9:49 AM
    Tuesday, September 20, 2011 6:13 AM
    Moderator

All replies

  • Hi Jim

    Something like this should work

        Dim tbl As word.Table
        Dim rw As word.Row
       
        Set tbl = Selection.Tables(1)
        Set rw = Selection.Rows(1)
        tbl.Rows.Add rw.Next


    Cindy Meister, VSTO/Word MVP
    Saturday, September 17, 2011 7:38 AM
    Moderator
  • Thank you Cindy. Unfortunately, the step before that (the user selects something in the control) is where I'm stuck. MS left out an "OnChange" event.
    Monday, September 19, 2011 12:52 PM
  • Hi Jim

    The content control exit event is all you've got.

    That, or perhaps linking it to a node in a Custom XML Part, then using the StorageUpdate event. I believe that will trigger on selection.

    Please note that content controls were not designed to be used as "form fields". They're meant to assist in buidling structured documents. According to this design, it's not to be expected that a selection in a content control will change content elsewhere in the document "on change". If you need that kind of behavior, then use a legacy form field, ActiveX control, or a control not on the document surface.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Liliane Teng Friday, September 23, 2011 9:49 AM
    Tuesday, September 20, 2011 6:13 AM
    Moderator