Changing the selection position

S

S Shulman

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
 
J

Jay Freedman

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
 
H

Helmut Weber

Hi,
thousand and more ways!
Have you tried to use the macro-recorder
and to record a changing of the selection?
As far as tables are concerned, like this:
ActiveDocument.Tables(1).Cell(1, 1).Select
Note that cell is defined by row and column,
.... cell(rwo,column).select
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top