Solved

Easy Word/Visual Basic Question "Selections"

Posted on 2000-03-09
13
191 Views
Last Modified: 2013-11-25
Hey, I can't quite figure something out.  Keep in mind I'm not using real VB, I'm using Word VB.

I can place things in my document and I can have different things select and such, but is there a way I can have the cursor go to the last line of a specificed page?  I was hoping there was a command like:

"Activedocument.MoveEndOfPage"

There isn't one, unfortunately.  Any equivelant to do such?

Thanks for any help..

0
Comment
Question by:saksafon2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2602330
Have you looked at the Goto method of the Selection object?  It looks like this syntax might work after you select the page/document/whatever:

Selection.Goto Which:=wdGoToLast

Wes
0
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2602339
This is from Word Help regarding the .End property:

This example retrieves the ending position of the selection. This value is used to create a range so that a field can be inserted after the selection.

pos = Selection.End
Set myRange = ActiveDocument.Range(Start:=pos, End:=pos)
ActiveDocument.Fields.Add Range:=myRange, Type:=wdFieldAuthor

Wes
0
 
LVL 1

Expert Comment

by:paul_tsekov
ID: 2602409
Hi VBfan,
 if there is a thing like ActiveDocument.SetFocus

then you could use the three following rows:

  ActiveDocument.SetFocus
  SendKeys "{PGDN}"
  SendKeys "{Home}"

ghgfgh
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:wesleystewart
ID: 2602456
That would certainly work, but I would avoid SendKeys like the plague.  If that's the only way you can do it that's fine, but otherwise . . .

Wes
0
 

Author Comment

by:saksafon2
ID: 2604331
I'm working with not-very intelligent people.
Sending something flimsy like a sendkey might cause problems down the road.

Thanks for the response, though!

rick
0
 

Author Comment

by:saksafon2
ID: 2604359
^^ About my comment, don't take that the wrong way, I just read my comment over and laughed.  I meant it as the people I'm working with on my job.  Someone might mess with the document and throw things off.. lol

rick
0
 

Author Comment

by:saksafon2
ID: 2604382
Adjusted points to 30
0
 

Author Comment

by:saksafon2
ID: 2604383

Wes, I see what your saying about the Goto end..
How can I go about selecting the entire page (including <CR>'s) so that this will work?

rick


0
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2604421
Did you try:

ActiveDocument.Select
Selection.Goto Which:=wdGoToLast

That might be a little cludgy.  I'll see if I can find something else.

Wes
0
 

Author Comment

by:saksafon2
ID: 2604829
Thats the right track, except

"ActiveDocument.Select"...

selects the entire 4 page document.  I'd like it to suggest just the first page.. Hmmm..

I'm figuring it would be similar to "ActiveDocument.Paragraphs(1).Range.Select"

Like.. "ActiveDocument.Page(1).Range.Select", but page isn't an ob.

Hm!

rick
0
 
LVL 4

Accepted Solution

by:
wesleystewart earned 50 total points
ID: 2604895
Here's another useful widget:

Selection.InsertAfter "End of section 1."

It looks like the InsertAfter takes you to teh end of the selection also.

Alas, I couldn't find any Pages property.  It looks like paragraphs will have to do.

You can access Sections of the document with:

Document.Sections(1)

if you have split your document into sections, which you can do with >>Insert>>Break

Wes
0
 

Author Comment

by:saksafon2
ID: 2605100
Wonderful!  Your comment about adding the Sections did it.  Here is the outcome:

What I needed to do was place a signature line and a few other lines of text at the end of the page.  It tried just having a bookmark to go to, but when I'd have my variable body text added, it would push the bookmark down and make it impossible to line up.  Now, the end of page 1 is a section break.

ActiveDocument.Sections(1).Range.Select
Selection.GoTo.EndOf (wdSection)
Selection.MoveUp unit:=wdLine, Count:=10

I select the first section (which is page one), go to the end of the section which kicks the cursor to the opening of page two, and bring it up ten lines to place the information where I needed it.

Thanks for your help!  I appreciate your efforts.

-Rick Detroit
0
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2605118
Happy to help.  

Good Luck in the future.  Word seems to have the most convoluted object model of all the Office products . . .

Wes
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question