This is the final code.
Sub subNumberTableColumns()
Dim objTable As Table
Dim intRowNo As Integer
Dim intCounter As Integer
On Error GoTo Error_subNumberTableColumns
'---------------------------------------------------------------
' Must be in a table to delete it
If funIsTable = False Then
MsgBox "You must be in a table to number the table.", vbCritical, "Number Block"
GoTo Exit_subNumberTableColumns
Else ' In a table
Set objTable = Selection.Tables(1)
intRowNo = objTable.Rows.Count ' Rows in the table
objTable.Cell(2, 1).Select ' Go to the cell below the header
'---------------------------------------------------------------
' Enter numbers in each row
For intCounter = 1 To intRowNo - 1 ' Number of rows minus the header
Selection.HomeKey Unit:=wdLine ' Start of the line
Selection.Range.Text = intCounter & ". "
Selection.MoveDown
Next intCounter
End If
Exit_subNumberTableColumns:
On Error GoTo 0
Exit Sub
Error_subNumberTableColumns:
MsgBox "An unexpected situation arose in your program." & vbCrLf & _
"Please write down the following details:" & vbCrLf & vbCrLf & _
"Module Name: " & "(MODULE_NAME)" & vbCrLf & _
"Type: VBA Document: " & vbCrLf & _
"Calling Procedure: " & "(PROCEDURE_NAME}" & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Descritption: " & Err.Description & vbCrLf & vbCrLf & _
"Resume Exit_" & "(PROCEDURE_NAME)" & vbCrLf & _
"Resume"
End Sub
Thanks Greg
|