Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing cursor in document

Status
Not open for further replies.

Luongo1

Programmer
Oct 13, 2006
52
CA
Hi, I received some great help on my last question so I just have one more for another project I'm working on. I'd like to have the user fill out a form, and when it's completed, place the cursor at a certain point in the document. Could someone tell me how this is done? It seems like it should be fairly simple, but I haven't been able to find it anywhere. Thanks...
 
The macro recorder gives:
Selection.MoveDown Unit:=wdLine, Count:=numLines
Selection.MoveRight Unit:=wdCharacter, Count:=numChars


where "numLines" is the number of lines from the top to move down, and "numChars" is the number of characters to move right from the left margin.


_________________
Bob Rashkin
 
It's a form to create a memo that pops up when the template is opened/new document created. I have yet to try Bong's suggestion though - I will give it a go today.
 
The best way (IMHO) is to put a bookmark at the location you want to go to, then go there. Using any sort of real movement of the Selection (.MoveDown, .MoveRight, .MoveLeft...etc) seems to be possibly unreliable. All it would take is one addition (or removal) of a line would mess up the movement.

Go to the location you want the cursor to end up at, put a bookmark there, say "GoHere".

And the end of whatever it is you are doing:[vba]Selection.GoTo What:=wdGoToBookmark, Name:="GoHere"[/vba]

Done. Bookmarks ARE specific locations. Essentially, they are a voice of Word saying..."Here". Their main advantage is that any text inserted before them will move the bookmark, true...but "Here" will always be....uh, there.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top