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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With