View Single Post
 
Old 06-21-2021, 08:25 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 of
Default

Your code works in Word 2019, assuming there are two tables in the document. It adds a copy of the table to the bottom of table 2. You can do it without the paste if you wish e.g.


Code:
Private Sub CommandButton1_Click()
Dim oRng As Range
Dim oFld As FormFields
Dim i As Long
    If ActiveDocument.ProtectionType <> wdNoProtection Then
        ActiveDocument.Unprotect
    End If
    With ActiveDocument
        Set oRng = ActiveDocument.Tables(2).Range
        oRng.Collapse wdCollapseEnd
        oRng.FormattedText = ActiveDocument.Tables(2).Range.FormattedText

        Set oFld = oRng.FormFields
        For i = 1 To oFld.Count
            oFld(i).Select
            If oFld(i).Type = wdFieldFormDropDown Then
                oFld(i).Result = oFld(i).DropDown.ListEntries(1).Name
            Else
                oFld(i).Result = ""
            End If
        Next
    End With
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
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