试试看,似乎对我有用
- Option Explicit
- Function GetTableCell(ByVal oTable As AcadTable, ByVal varPt As Variant, _
- ByRef rowIndex As Long, ByRef colIndex As Long) As Variant
- Dim wviewVec As Variant
- Dim resVar(1) As Long
- wviewVec = ThisDrawing.GetVariable("VIEWDIR")
- oTable.HitTest varPt, wviewVec, rowIndex, colIndex
- resVar(0) = rowIndex
- resVar(1) = colIndex
- GetTableCell = resVar
-
- End Function
- Sub test()
- Dim ar As Variant, _
- e As AcadEntity, _
- t As AcadTable, _
- p As Variant, _
- ip As Variant, _
- r As Long, _
- c As Long
-
- With ThisDrawing.Utility
- .GetEntity e, ip, "Select table"
- p = .GetPoint(, "Pick point in cell")
- End With
- Set t = e
- ar = GetTableCell(t, p, r, c)
- r = ar(0)
- c = ar(1)
-
- MsgBox "Row " & r & ", Column " & c & vbCr & _
- "Value: " & t.GetText(r, c)
- End Sub
~&039;J#039~ |