View Single Post
 
Old 08-10-2012, 03:17 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,346
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Yes, you can use Content Controls for a form. The attached works with or without the restrictions that apply to forms protection or the docx/m-format editing restrictions. It is currently configured for the latter. Simply exiting the last content control in the table will trigger the prompt that asks whether to add a new row. The dropdowns are presently not populated but, if you populate them, you'll see that their selection options are replicated when you add a new row.

To insert the new row immediately above the last row in the table, you could modify the ContentControlOnExit macro in the document by inserting:
'Break the table before the last row
.Last.Range.InsertBreak wdColumnBreak
after:
With Selection.Tables(1).Rows
and deleting or commenting-out:
.Next.InsertBefore vbCr

With that change, the penultimate table row will be replicated.

Note: As coded, you'll get two prompts if you answer 'no' to the addrow question if you click on another content control when exiting the last one in the table. If that annoys you, you could delete the lines:
Code:
'Exit if we're not in a table - we don't really need this is using a bookmarked table,
' but it's a safeguard against the bookmark having been expanded/moved.
If CCtrl.Range.Information(wdWithInTable) = False Then Exit Sub
Attached Files
File Type: docm Content Controls - Table Row Add.docm (48.4 KB, 369 views)
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote