Using VBA for Word, how do I create a range of table cells?

I am trying to learn how to handle Range objects in Word VBA regarding MS Word tables.

Using Range Object Help , it looks like I can create a range of cells while the cells are adjacent, however I can't seem to get the syntax for specifying the start and end points of the range using the cells.

For example:

Set rngCells = myTable.Range(Start:=<cell>, End:=<cell>) 

I'm not sure what to enable to indicate that the cell is starting or the cell is ending. Can someone give me a key? :)

Edit: I already created the table from scratch - I'm trying to use a series of cells for some rows in the middle to apply them to formatting. In particular, I'm trying to figure out if this can be done without using Selection.

+7
ms-word word-vba range cell
source share
1 answer

I found the answer I was looking for:

 Set myCells = ActiveDocument.Range(Start:=ActiveDocument.Tables(1).Cell(1, 1).Range.Start, _ End:=ActiveDocument.Tables(1).Cell(1, 1).Range.End) 

I did not understand that the Range object was from a Document object, not a Table object.

+4
source share

All Articles