View Single Post
 
Old 06-28-2021, 12:01 PM
ananas1171 ananas1171 is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2021
Posts: 5
ananas1171 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Based on your screenshot


Code:
Private Sub CommandButton1_Click()
Dim oCC As ContentControl
Dim oTable As Table
Dim oRng As Range
    Set oTable = ActiveDocument.Tables(1)
    For Each oCC In oTable.Range.ContentControls
        oCC.LockContentControl = False
    Next oCC
    oTable.Rows.Last.Range.Copy
    Set oRng = oTable.Range
    oRng.Collapse 0
    oRng.Paste
    oRng.ContentControls(1).DropdownListEntries.Item(1).Select
    For Each oCC In oTable.Range.ContentControls
        oCC.LockContentControl = True
    Next oCC
    Set oCC = Nothing
    Set oTable = Nothing
    Set oRng = Nothing
End Sub

Private Sub CommandButton2_Click()
Dim oCC As ContentControl
Dim oTable As Table
    Set oTable = ActiveDocument.Tables(1)
    For Each oCC In oTable.Range.ContentControls
        oCC.LockContentControl = False
    Next oCC
    oTable.Rows.Last.Delete
    For Each oCC In oTable.Range.ContentControls
        oCC.LockContentControl = True
    Next oCC
    Set oCC = Nothing
    Set oTable = Nothing
End Sub


Thanks for the response, this worked like a charm. I am experiencing issues when I try to restrict the form and to only allow fill out information in certain fields. When I lock the form and click add or remove row I receive the following;


Run time error '4605', This command is not available.

Based on the your previous posting on other links, I saw that you had a code regarding restrictions of form editing. I am guessing there has to be a code for password. I am trying to figure out how to apply this. Would be able to help me again?
Attached Images
File Type: png Remove column.PNG (33.3 KB, 17 views)
File Type: png Add Column.PNG (45.8 KB, 17 views)
Reply With Quote