Question

I'm trying to learn how to handle Range objects in Word VBA with regards to MS Word tables.

Using the Range object help, it would seem I can create a range of cells as long as the cells are contiguous, however I cannot seem to get the syntax for specifying the Start and End points of the range using cells.

For example:

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

I'm not sure what to put in for to indicate the cell to start or the cell to end with. Can someone give me a clue? :)

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

Was it helpful?

Solution

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 realize the Range object was from the Document object, not the Table object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top