'检查光标是否处于表格内
If Selection.Information(wdWithInTable) = False Then Exit Sub
'选择表格内第2行第2列到第3行第3列的单元格区域
Selection.SetRange Start:=Selection.Tables(1).Cell(2, 2).Range.Start, End:=Selection.Tables(1).Cell(3, 3).Range.End
Dim strText As String
Dim objRow As Row
If Selection.Information(wdWithInTable) = False Then Exit Sub
strText = InputBox$('输入想要删除的文本:', '删除行')
For Each objRow In Selection.Tables(1).Rows
If objRow.Cells(1).Range.Text = strText & vbCr & Chr(7) Then objRow.Delete
Next objRow
Dim objRange As Range
Dim objCell As Cell
For Each objCell In Selection.Tables(1).Columns(1).Cells
Set objRange = objCell.Range
objRange.SetRange Start:=objRange.Start, End:=objRange.End - 1
MsgBox objRange.Text
Next objCell
Dim objCell As Cell
For Each objCell In ActiveDocument.Tables(1).Range.Cells
objCell.Select
MsgBox '跨行数 = ' & _
(Selection.Information(wdEndOfRangeRowNumber) - _
Selection.Information(wdStartOfRangeRowNumber)) + 1
Next objCell
联系客服