View Single Post
 
Old 06-21-2021, 12:19 PM
Mark6455 Mark6455 is offline Windows 10 Office 2019
Novice
 
Join Date: Jun 2021
Posts: 7
Mark6455 is on a distinguished road
Default Word 2019 will not properly run macro

I have a document created in Word 2016. When I open and run the macro with Word 2019, the macro returns an error for Selection.paste. There is a 'button' that runs this macro on a police duty report. The macro copies and then adds a new entry form for another event if needed. Any help appreciated. The following is the VBA:

Private Sub CommandButton1_Click()
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
With ActiveDocument
.Tables(2).Range.Copy
.Range.Select
Selection.Collapse wdCollapseEnd
Selection.Paste

Dim oRng As Range
Dim oFld As FormFields
Dim i As Long
Set oRng = ActiveDocument.Tables(2).Range
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
Private Sub OptionButton4_Click()

End Sub
Private Sub OptionButton6_Click()

End Sub
Reply With Quote