VBA - selects current table cursor is in

F

Fred

Also require macro that will select all but first row of table cursor is
positioned in:


Sub TableExcept1stRow()

ActiveDocument.Tables(1).Select
Selection.SetRange _
Start:=Selection.Rows(2).Range.Start, _
End:=Selection.End

End Sub

Thank you.
 
H

Helmut Weber

Hi Fred

how about this,
which would include the end of row mark.
With vertically merged cells things would be different.


Sub Test004567()
Dim rngTmp As Range
Set rngTmp = selection.Tables(1).Range
rngTmp.start = rngTmp.Rows(2).Cells(1).Range.start
rngTmp.Select
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
G

Greg Maxey

Try:
Sub Scratchmacro()
Dim oRng As Word.Range
If Selection.Information(wdWithInTable) Then
Set oRng = Selection.Range
With oRng
.Start = Selection.Tables(1).Rows(2).Range.Start
.End = Selection.Tables(1).Rows.Last.Range.End
.Select
End With
Else
MsgBox "The selection is not in a table"
End If
End Sub
 
F

Fred

Thanks Greg also does the trick.
Greg Maxey said:
Try:
Sub Scratchmacro()
Dim oRng As Word.Range
If Selection.Information(wdWithInTable) Then
Set oRng = Selection.Range
With oRng
.Start = Selection.Tables(1).Rows(2).Range.Start
.End = Selection.Tables(1).Rows.Last.Range.End
.Select
End With
Else
MsgBox "The selection is not in a table"
End If
End Sub
 
Top