tags:

views:

29

answers:

1

In using or setting Ranges, some Ranges behave differently that other Ranges. For example,

ActiveDocument.Range(10, 20).Select
ActiveDocument.Tables(2).Cell(1, 1).Range(10, 20).Select

The first line if OK and works as expected. The second line produces an error on the Range statement, although it seems that two lines should be identical for this.

What is the difference?

+3  A: 

Range on a Cell is a property, not a method -- it returns the range of the document represented by the cell.

This means you can't add arguments like (10,20).

The following is equivalent:

 Dim rangeStart As Integer
 rangeStart = ActiveDocument.Tables(2).Cell(1, 1).Range.Start
 ActiveDocument.Range(rangeStart + 10, rangeStart + 20).Select
Jay