Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-21-2018, 04:25 PM
jeffreybrown jeffreybrown is offline Loop thru document and create bookmarks Windows Vista Loop thru document and create bookmarks Office 2007
Expert
Loop thru document and create bookmarks
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Loop thru document and create bookmarks

I have numbered paragraphs which start with the word Step followed by a sequence field.



Step {SEQ MyStep }

1.1. Step 1
1.2. Step 2
1.3. This is a paragraph without a step
1.4. Step 3
1.5. This is a paragraph without a step
1.5. Step 4
etc

How can I loop through the numbered paragraphs turning the Step 1 etc into bookmarks? It would be nice to have the bookmarks named MyStep1, MyStep2 and so on.
Reply With Quote
  #2  
Old 09-21-2018, 08:29 PM
macropod's Avatar
macropod macropod is offline Loop thru document and create bookmarks Windows 7 64bit Loop thru document and create bookmarks Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Is there a reason for using SEQ fields rather that Word's multi-level list numbering? The latter allows you insert a cross-reference to a numbered item without the need to create a bookmark.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-21-2018, 08:34 PM
gmayor's Avatar
gmayor gmayor is offline Loop thru document and create bookmarks Windows 10 Loop thru document and create bookmarks Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Assuming this is an accurate reflection of your document and the numbers are outline numbers and not text then
Code:
Sub Macro1()
'Graham Mayor - http://www.gmayor.com - Last updated - 22 Sep 2018
Dim oPara As Range
Dim iCount As Integer: iCount = 1
Dim iPara As Integer
    For iPara = 1 To ActiveDocument.Paragraphs.Count
        If ActiveDocument.Paragraphs(iPara).Range.Words(1) Like "Step*" Then
            Set oPara = ActiveDocument.Paragraphs(iPara).Range.Words(1)
            oPara.Bookmarks.Add "Step" & iCount
            iCount = iCount + 1
        End If
    Next iPara
lbl_Exit:
    Set oPara = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 09-22-2018, 06:04 AM
jeffreybrown jeffreybrown is offline Loop thru document and create bookmarks Windows Vista Loop thru document and create bookmarks Office 2007
Expert
Loop thru document and create bookmarks
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Quote:
Is there a reason for using SEQ fields rather that Word's multi-level list numbering? The latter allows you insert a cross-reference to a numbered item without the need to create a bookmark.
The paragraph numbering is already setup with the multi-level list numbering. Auto Text is used to populate "Step x" as the user begins to type "Step" and then simply presses enter. Of course, not sure what process will work best, so experimenting with different methods. I also have to cross-reference to other paragraphs, so I will use the built in cross-reference to paragraph numbers.

Create Sequence Fields for Interrogatories and More

After the document is written by the user, I plan to have a customized ribbon for the user to create the bookmarks. I played around with the "Caption" option, but it appears if you enter a "Caption" right after the paragraph numbering, the numbering is removed in place of the caption. The Auto Text seems a better option.

Quote:
Assuming this is an accurate reflection of your document and the numbers are outline numbers and not text then
Thanks Graham, this work great.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop thru document and create bookmarks split word document based on bookmarks with each new document title of the bookmark megatronixs Word VBA 9 09-05-2020 02:29 PM
Loop thru document and create bookmarks How to create a list of bookmarks? dharker Word VBA 5 10-19-2016 03:08 PM
Create Index List Using Bookmarks in Alphabetical Order priteshp108 Word VBA 8 11-16-2015 12:06 PM
Loop thru document and create bookmarks How do I create slideshow that plays on loop? Olwen PowerPoint 1 08-25-2011 11:55 AM
Using bookmarks in a protected document Bill Stemp Word 0 10-16-2010 06:47 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:54 AM.


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