View Single Post
 
Old 06-25-2021, 08:36 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote