word 2010 Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="3"

Hello from Steved


Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="3" "and it goes to page 3"


Looking at the above, I have a "5 Page" document And I want to run a macro only on the page Selected, in this case "Page 3" is this possible please.


My end goal is no matter where I'm at in a document I only want the "Macro" too deal with the selected "Page Only".


So far I've tried to change this script     If Selection.End = ActiveDocument.Bookmarks("\Sel").Range.End Then

I've the changed it to     If Selection.End = ActiveDocument.Bookmarks("\Page").Range.End Then


My thinking is, If I know how to put in Bookmarks ( I do not know how to go about this } at the end of each page My question then being can VBA  go to that particular bookmark and tell the macro to stop. Maybe this is an option I just don't know.

Thank you.

Answer
Answer

If you paid more attention to what I posted, you would know to use something like:

 

Dim Rng As Range
Set Rng = ActiveDocument.GoTo(What:=wdGoToPage, Name:="3")
Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\page")

With Rng.Find
     .Text = "R 0:0:0"
     .Replacement.Text = "L 0:0:0"
     .Forward = True
     .Wrap = wdFindStop
     .Format = False
     .MatchWildcards = True
     .Execute Replace:=wdReplaceAll
End With

Cheers
Paul Edstein
(Fmr MS MVP - Word)

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 9, 2023 Views 7,816 Applies to: