Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 01-14-2015, 12:58 PM
macropod's Avatar
macropod macropod is offline Selection.Bookmarks("\headinglevel") WITHOUT Selection Windows 7 64bit Selection.Bookmarks("\headinglevel") WITHOUT Selection Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
 



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.Bookmarks("\headinglevel") WITHOUT Selection 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
Selection.Bookmarks("\headinglevel") WITHOUT Selection Macro VBA "Save as" with bookmarks in file name string Dom37 Word VBA 2 10-31-2011 03:28 AM
Selection.Bookmarks("\headinglevel") WITHOUT Selection 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft