![]() |
#16
|
|||
|
|||
![]()
Oh, I'm sorry, I'm such a novice at this, I thought I had created the correct thing, but let me review it and try and do this correctly.
Thank you so much for your help. |
#17
|
||||
|
||||
![]()
It can be done with formfields, too. See, for example, 'An alternative method of adding a row to a protected table' at: http://www.gmayor.com/word_vba_examples_2.htm
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#18
|
|||
|
|||
![]()
I've added the content controls and also put included a snapshot of the rows I'm trying to repeat. Thank you.
|
#19
|
||||
|
||||
![]()
Try your document with the following code:
Code:
Option Explicit Dim bLastCell As Boolean Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl) With Selection If .Information(wdWithInTable) = True Then With ActiveDocument.Tables(2).Range If Selection.Cells(1).RowIndex = .Cells(.Cells.Count).RowIndex Then If Selection.Cells(1).ColumnIndex = .Cells(.Cells.Count).ColumnIndex Then bLastCell = True End If End If End With End If End With End Sub Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Application.ScreenUpdating = False Dim CCtrl As ContentControl, Prot As Long, Pwd As String, i As Long, j As Long If bLastCell = True Then If Selection.Tables(1).Range = ActiveDocument.Tables(2).Range Then If MsgBox("Add new row?", vbQuestion + vbYesNo) = vbYes Then If ActiveDocument.ProtectionType <> wdNoProtection Then Pwd = "" 'Insert password here Prot = ActiveDocument.ProtectionType ActiveDocument.Unprotect Password:=Pwd End If ContentControl.Range.Select Selection.SplitTable ContentControl.Range.Select Selection.Tables(1).Rows.Last.Range.Characters.Last.Next.InsertBefore vbCr With Selection.Tables(1).Rows .Last.Range.Copy .Last.Range.Next.Paste For Each CCtrl In .Last.Range.ContentControls With CCtrl If .Type = wdContentControlCheckBox Then .Checked = False If .Type = wdContentControlRichText Or .Type = wdContentControlText Then .Range.Text = "" If .Type = wdContentControlDropdownList Then .DropdownListEntries(1).Select If .Type = wdContentControlComboBox Then .DropdownListEntries(1).Select If .Type = wdContentControlDate Then .Range.Text = "" .LockContentControl = True End With Next .First.Range.Characters.First.Previous.Delete End With ActiveDocument.Protect Type:=Prot, Password:=Pwd End If End If bLastCell = False End If Application.ScreenUpdating = True End Sub 1. you're working with the second table in the document, whereas the example had only one; and 2. your table has vertically-split cells (which makes it impossible to work with a row designation. PS: I note you now have a mix of content controls and formfields in your document. You really should use one or the other - they are not designed to work together.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
LAssist2011 | Word | 5 | 12-14-2011 03:02 PM |
![]() |
jwm1346 | Word | 1 | 11-17-2011 03:08 AM |
![]() |
Macieto | Word | 4 | 09-14-2011 04:53 AM |
![]() |
Keep on Ticking | Word | 1 | 06-23-2011 03:29 AM |
Form Fields | questions | Word | 0 | 04-27-2009 10:48 AM |