Sub test()
Dim t1 As Object
Dim t2 As Object
Dim i As Integer
If Selection.Information(wdWithInTable) = True Then
Set t1 = Selection.Tables(1)
For i = 1 To ActiveDocument.Tables.Count
Set t2 = ActiveDocument.Tables(i)
If t1 = t2 Then
MsgBox "這是tables(" & i & ")"
End If
Next
Else
MsgBox "游標不在表內"
End If
End Sub
Sub test()
Dim t1 As Object
Dim t2 As Object
Dim i As Integer
If Selection.Information(wdWithInTable) = True Then
Set t1 = Selection.Tables(1)
For i = 1 To ActiveDocument.Tables.Count
Set t2 = ActiveDocument.Tables(i)
If t1 = t2 And t1.Range.End = t2.Range.End Then
MsgBox "這是tables(" & i & ")"
End If
Next
Else
MsgBox "游標不在表內"
End If
End Sub
uj5u.com熱心網友回復:
修訂一下,加個條件
Sub test()
Dim t1 As Object
Dim t2 As Object
Dim i As Integer
If Selection.Information(wdWithInTable) = True Then
Set t1 = Selection.Tables(1)
For i = 1 To ActiveDocument.Tables.Count
Set t2 = ActiveDocument.Tables(i)
If t1 = t2 And t1.Range.End = t2.Range.End Then
MsgBox "這是tables(" & i & ")"
End If
Next
Else
MsgBox "游標不在表內"
End If
End Sub
厲害!
不過其實不用“加條件”,代碼第11行只要這樣就行了:
If t1.Range.End = t2.Range.End Then
uj5u.com熱心網友回復:
修訂一下,加個條件
Sub test()
Dim t1 As Object
Dim t2 As Object
Dim i As Integer
If Selection.Information(wdWithInTable) = True Then
Set t1 = Selection.Tables(1)
For i = 1 To ActiveDocument.Tables.Count
Set t2 = ActiveDocument.Tables(i)
If t1 = t2 And t1.Range.End = t2.Range.End Then
MsgBox "這是tables(" & i & ")"
End If
Next
Else
MsgBox "游標不在表內"
End If
End Sub
厲害!
不過其實不用“加條件”,代碼第11行只要這樣就行了:
If t1.Range.End = t2.Range.End Then