Solved

Easy Word/Visual Basic Question "Selections"

Posted on 2000-03-09
13
183 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

746 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

13 Experts available now in Live!

Get 1:1 Help Now