Solved

Extend selectin to beginnig of document.

Posted on 2011-03-11
1
158 Views
Last Modified: 2012-05-11
Can someone tell me why this code does not keep selected the page that contains "secondary".  Should be easy to tell what I am tryign to do.  I want to find the page that contains "secondary" and then select that page and everything else before it.  Instead it is selecting all pages before the one that contains "secondary"
Sub Macro1()
'
' Macro1 Macro
'
'
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "secondary"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
ActiveDocument.Bookmarks("\Page").Range.Select
Selection.HomeKey wdStory, wdExtend



End Sub

Open in new window

0
Comment
Question by:BigWill5112
1 Comment
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 500 total points
Comment Utility
The code you show seems to act as if you clicked the mouse on the top character of the page "secondary" page, held down Shift, and then clicked at the bottom character of the page. If you press Ctrl-Shift-Home at this point, the selection is anchored at the top of the "secondary" page, not the bottom. I would suggest you just change line 21 to:

Selection.Start = 0

which explicitly changes the beginning of the selection and does not the affect the end.

Hope this helps,
pT72
0

Featured Post

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

Join & Write a Comment

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

728 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

14 Experts available now in Live!

Get 1:1 Help Now