Option Explicit
Sub NextCell()
Dim iActiveColumn As Integer
Dim iColumnCount As Integer
Dim iActiveRow As Integer
Dim iRowCount As Integer
iActiveColumn = Selection.Information(wdEndOfRangeColumnNumber)
iColumnCount = Selection.Information(wdMaximumNumberOfColumns)
iActiveRow = Selection.Information(wdEndOfRangeRowNumber)
iRowCount = Selection.Information(wdMaximumNumberOfRows)
If iActiveColumn < iColumnCount Or _
iActiveRow < iRowCount Then
Selection.MoveRight Unit:=wdCell, _
Count:=1, _
Extend:=wdMove
Else
Selection.Tables(1).Cell(1, 1).Select
End If
End Sub
Sub AddATable()
Dim oRange As Word.Range
Dim oTable As Word.Table
Set oRange = ActiveDocument.Bookmarks("bmTable").Range
Set oTable = ActiveDocument.Tables.Add(Range:=oRange, _
NumRows:=3, _
NumColumns:=3, _
AutoFitBehavior:=wdAutoFitFixed)
oTable.AutoFormat Format:=wdTableFormatColorful2
oTable.Cell(1, 1).Select
Set oRange = Nothing
Set oTable = Nothing
End Sub
|