[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Extend selectin to beginnig of document.

Posted on 2011-03-11
1
Medium Priority
?
164 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
[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
1 Comment
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 2000 total points
ID: 35113150
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses

656 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