Option Explicit
Sub NextCell()
Dim iActiveColumn As Integer
Dim iColumnCount As Integer
Dim iActiveRow As Integer
Dim iRowCount As Integer
'Get position of cursor
iActiveColumn = Selection.Information(wdEndOfRangeColumnNumber)
iColumnCount = Selection.Information(wdMaximumNumberOfColumns)
iActiveRow = Selection.Information(wdEndOfRangeRowNumber)
iRowCount = Selection.Information(wdMaximumNumberOfRows)
'Check if where in last cell
If iActiveColumn < iColumnCount Or _
iActiveRow < iRowCount Then
'Not in the last cell so do normal move
Selection.MoveRight Unit:=wdCell, _
Count:=1, _
Extend:=wdMove
Else
'Yepz in the last cell go to first cel
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
'Add table to range of bookmark (oRange)
Set oTable = ActiveDocument.Tables.Add(Range:=oRange, _
NumRows:=3, _
NumColumns:=3, _
AutoFitBehavior:=wdAutoFitFixed)
'Add special table format
oTable.AutoFormat Format:=wdTableFormatColorful2
oTable.Cell(1, 1).Select
Set oRange = Nothing
Set oTable = Nothing
End Sub
|