TButhe
09-19-2006, 09:53 AM
I am trying to create macro that will look at the row that the cursor is in and if that row is less than or equal to 13 then I want it to display a message box telling the user they cannot delete that row. I can do this in excel no prob but can't quite get it in Word. I got the rest of the code off this site. (Thanks, everyone.) :clap: :clap:
Here is what I have so far.
Sub CustomDeleteRow()
If Selection.Information(wdWithInTable) Then
With ActiveDocument
If .ProtectionType <> wdNoProtection Then .Unprotect Password:="password"
'this is where i run into problems - at least i think this is the spot
If ActiveDocument.Tables.Rows.Count <= 13 Then _
MsgBox ("You cannot delete this row."), vbOKOnly
Dim myCheck As VbMsgBoxResult
myCheck = MsgBox("Are you sure you want to delete this row?", vbYesNo)
If myCheck = vbYes Then
Selection.Rows(1).Delete
Else
Exit Sub
End If
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="password"
End With
Else
Exit Sub
End If
End Sub
Any help is greatly appreciated!! Thanks. :bow:
</IMG></IMG>
Here is what I have so far.
Sub CustomDeleteRow()
If Selection.Information(wdWithInTable) Then
With ActiveDocument
If .ProtectionType <> wdNoProtection Then .Unprotect Password:="password"
'this is where i run into problems - at least i think this is the spot
If ActiveDocument.Tables.Rows.Count <= 13 Then _
MsgBox ("You cannot delete this row."), vbOKOnly
Dim myCheck As VbMsgBoxResult
myCheck = MsgBox("Are you sure you want to delete this row?", vbYesNo)
If myCheck = vbYes Then
Selection.Rows(1).Delete
Else
Exit Sub
End If
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="password"
End With
Else
Exit Sub
End If
End Sub
Any help is greatly appreciated!! Thanks. :bow:
</IMG></IMG>