![]() |
|
#4
|
||||
|
||||
|
Not without use Selection. You could, of course, use something like the following, so your original selection is restored once the macro has finished:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, Rng As Range
Set Rng = Selection.Range
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.Style = "Heading 2"
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
i = i + 1
.Duplicate.Select
MsgBox Selection.Bookmarks("\HeadingLevel").Range.Text
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Rng.Select
Application.ScreenUpdating = True
MsgBox i & " headings found."
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "Replace all" within a selection (Word 2007) | paulkaye | Word | 5 | 02-19-2013 01:25 AM |
Selection of all Text for a specific page in word is spanning selection across pages
|
ramsgarla | Word VBA | 9 | 12-05-2012 03:23 AM |
Macro VBA "Save as" with bookmarks in file name string
|
Dom37 | Word VBA | 2 | 10-31-2011 03:28 AM |
How to choose a "List" for certain "Heading" from "Modify" tool?
|
Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |
| How to fix "create bookmarks using headings" as default when saving to PDF using Word | ghumdinger | Word | 0 | 05-05-2011 02:11 AM |