How to move up &down insertpoint in a document

S

SAM

Hi!

I have a document (word 2003) with text and i wish insert some text in some diferent
locations.

How can i create a subroutine to move the insertion point in relation of the top of the
page or document?

private sub set_position(lines as integer)
rem lines as the number of lines i wish move down from the top of page/doc
dim range1 as range
set range1=application.activedocument.range(0.0)
rem convert range at insertion point
range1.collapse(wdEnd)
range1.movedown(lines)
end sub


i have very confused with objects "range" and "selection" ....

thansks!
 
G

Gordon Bentley-Mix

If the insertion point is always the same, it would probably be much easier
to place a bookmark or bookmarks at the target location(s) and insert the
text into the range(s) specified by the bookmark(s). Trying to determine the
insertion point relative to the top of the document/page is probably much
more work that it's worth, especially as the point can move as you add
content to the document. (In addition, many other variables can cause the
number of "lines" and "pages" to change - the default printer, for example.)

However, if you *must* use this approach - and I can't think of any good
reason why this would be the case - then I'd recommend starting your
insertions from the bottom of the document and moving up; at least that way
you'll minimise the impact that the additional content will have on changing
the relative position of the insertion points. In addition, I'd recommend
using the Selection object over the Range object whilst developing your code
so you can actually see the insertions as they're being made and get a bit
of visual feedback on what's happening in your document. You can revise the
code to use the Range object afterwards.

Good luck! I'm glad this is your project and not mine! ;-P
--
Cheers!

Gordon Bentley-Mix
Word MVP

in message news:[email protected]...
 

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