|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function GetTableSelectionDetails()
Dim strMsg As String
If Selection.Information(wdWithInTable) = True Then
Dim rngCurTable As Range
Set rngCurTable = Selection.Tables(1).Range
Dim rngCurSelect As Range
Set rngCurSelect = Selection.Range
Dim lngTblCellsCt As Long
Dim lngTblRowsCt As Long
Dim lngTblColsCt As Long
Dim lngSelCellsCt As Long
Dim lngSelRowsCt As Long
Dim lngSelColsCt As Long
' Count Cells, Rows and Columns in the selection.
lngSelCellsCt = Selection.Cells.Count
lngSelRowsCt = Selection.Rows.Count
lngSelColsCt = Selection.Columns.Count
' Count Cells, Rows and Columns in the table.
lngTblCellsCt = rngCurTable.Cells.Count
lngTblRowsCt = rngCurTable.Rows.Count
lngTblColsCt = rngCurTable.Columns.Count
If lngSelCellsCt = lngTblCellsCt Then ' there's a difference between all the cells and all cells in the table.
If rngCurTable.End = rngCurSelect.End Then
strMsg = "Entire table is selected (" & lngSelCellsCt & " cells)"
Else
strMsg = "All cells in table are selected (" & lngSelCellsCt & " cells)"
End If
Else
If lngSelColsCt = lngTblColsCt Then
strMsg = lngSelRowsCt & " rows are selected"
Else
If lngSelRowsCt = lngTblRowsCt Then
strMsg = lngSelColsCt & " columns are selected"
Else
strMsg = lngSelCellsCt & " cells are selected"
End If
End If
End If
Else
strMsg = "not in table at all"
End If
MsgBox strMsg
'Sub TESTTablePosition()
' Call GetTableSelectionDetails
'End Sub
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |