![]() |
|
|
|
#1
|
||||
|
||||
|
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 |
|
| Tags |
| macro, macro error |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What's new in Word 2019, Excel 2019 and Outlook 2019 and Why upgrade to Office 2019 is recommended? | einfomail | Office | 0 | 07-25-2019 11:49 AM |
| PgUp/PgDn not working as expected in Word 2019; macro workaround? | AmyJSchneider | Word VBA | 0 | 01-19-2019 03:45 PM |
Macro Enabled Word Doc Does not Properly Work on Different Machine
|
danjoe | Word VBA | 3 | 10-19-2017 05:49 AM |
| Macro does not run properly | dherr | Word VBA | 2 | 02-19-2015 08:50 AM |
| Word 2000 Macro not working properly | brianlb | Word VBA | 1 | 07-01-2009 07:04 AM |