O
Owen
I am using the following Macro in a protected form.
The intention of the macro is to determine if the cursor is within any of
Tables 4 to 8, and if the result is true then copy the current row from that
table and insert it in the row below.
For some reason, although the macro runs without errors, the new row is not
created even when i know my selection is within Tables 4 to 8.
Would be great if someone can spot the problem in my code.
Sub AddRevisionTableRow()
ActiveDocument.Unprotect
Dim oTbl As Table
For x = 4 To 8
With ActiveDocument
Set oTbl = .Tables(x)
If Selection.Range.InRange(oTbl.Range) Then
Selection.SelectRow
Selection.Copy
Selection.Collapse
Selection.MoveDown unit:=wdLine, Count:=1
Selection.Paste
Else
End If
End With
Next x
ActiveDocument.Protect (wdAllowOnlyFormFields), NoReset:=True
End Sub
The intention of the macro is to determine if the cursor is within any of
Tables 4 to 8, and if the result is true then copy the current row from that
table and insert it in the row below.
For some reason, although the macro runs without errors, the new row is not
created even when i know my selection is within Tables 4 to 8.
Would be great if someone can spot the problem in my code.
Sub AddRevisionTableRow()
ActiveDocument.Unprotect
Dim oTbl As Table
For x = 4 To 8
With ActiveDocument
Set oTbl = .Tables(x)
If Selection.Range.InRange(oTbl.Range) Then
Selection.SelectRow
Selection.Copy
Selection.Collapse
Selection.MoveDown unit:=wdLine, Count:=1
Selection.Paste
Else
End If
End With
Next x
ActiveDocument.Protect (wdAllowOnlyFormFields), NoReset:=True
End Sub