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
Solved

Easy Word/Visual Basic Question "Selections"

Posted on 2000-03-09
13
187 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

837 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