S said:
Hi all
I woder whether there is any way of changing the position of the
selection to another position e.g. a cell in a table
or just Go to end of document, beginning of document etc.
Thank you in advance
Shmuel
Hi Shmuel,
There are dozens of ways!
- You can use various methods of the Selection object: Selection.HomeKey,
Selection.EndKey, Selection.Move, MoveWhile, MoveUntil, MoveStart, MoveEnd,
etc...
- You can use the .Select method of many different kinds of objects: For
example, ActiveDocument.Paragraphs(1).Select will select the first paragraph
in the document, and ActiveDocument.Tables(1).Cell(2,3).Select will select
the cell in row 2 and column 3 of the first table in the document.
- You can use the Selection.Find property to move the selection to some
particular text or formatting you can search for.
All of these things are described in the VBA help. The quickest way to get
there is to type the word Selection in the VBA editor and press F1.
When you get more sophisticated about Word and VBA, you should look at using
a Range object instead of the Selection object for most work. Here's a
reference:
http://msdn.microsoft.com/library/en-us/modcore/html/decontheselectionobjectvsrangeobject.asp