Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 08-10-2012, 03:17 AM
macropod's Avatar
macropod macropod is offline Macro to add row to table in a Word form Windows 7 64bit Macro to add row to table in a Word form Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
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, 546 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to add row to table in a Word form Macro help sought for Word table xan Word VBA 1 04-20-2012 07:50 PM
Macro to add row to table in a Word form Create Table Form from Word Document gsj224 Word VBA 3 07-31-2011 09:26 AM
Macro to add row to table in a Word form Word Macro That Checks a Check Box Form Field When File Print is Executed DKerne Word VBA 4 06-09-2011 11:54 AM
Do I need a Form or a Macro?? Keith24249 Excel 0 08-23-2010 06:23 AM
Use Form Checkbox to Add Table laxonator Word Tables 0 10-23-2008 06:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft