Solved

Easy Word/Visual Basic Question "Selections"

Posted on 2000-03-09
13
184 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can i Install a new Data Source on Visual Studio 2 94
using Access 8 59
Dialogbox API leak? 18 81
clicking a shape in a frame array vb6 3 40
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now