Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 11-08-2013, 03:33 PM
step10 step10 is offline Tables with form fields Mac OS X Tables with form fields Office 2007
Novice
Tables with form fields
 
Join Date: Oct 2013
Location: USA
Posts: 11
step10 is on a distinguished road
Default

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.
Reply With Quote
  #17  
Old 11-08-2013, 04:15 PM
macropod's Avatar
macropod macropod is online now Tables with form fields Windows 7 32bit Tables with form fields Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

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]
Reply With Quote
  #18  
Old 11-12-2013, 07:58 AM
step10 step10 is offline Tables with form fields Windows 7 32bit Tables with form fields Office 2007
Novice
Tables with form fields
 
Join Date: Oct 2013
Location: USA
Posts: 11
step10 is on a distinguished road
Default updated form

I've added the content controls and also put included a snapshot of the rows I'm trying to repeat. Thank you.
Attached Files
File Type: zip TEST123 Move Form-REV13-macro.zip (54.9 KB, 10 views)
Reply With Quote
  #19  
Old 11-12-2013, 02:27 PM
macropod's Avatar
macropod macropod is online now Tables with form fields Windows 7 32bit Tables with form fields Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
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

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
The principal issues that had to be dealt with here are:
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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tables with form fields Form Fields - Create blank form text field with if statement? LAssist2011 Word 5 12-14-2011 03:02 PM
Tables with form fields Form Fields jwm1346 Word 1 11-17-2011 03:08 AM
Tables with form fields How to make two independent columns not using fields and tables Macieto Word 4 09-14-2011 04:53 AM
Tables with form fields Tab through fields on a form. Keep on Ticking Word 1 06-23-2011 03:29 AM
Form Fields questions Word 0 04-27-2009 10:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:03 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