![]() |
|
#1
|
|||
|
|||
![]()
Hello I found this macro and Im trying to modify it to fit my application.
If the word Roll Call exist, select it and insert a paragraph after it, insert a bookmark. Any leads would be appreciate it. Sub macro2() Set myRange = ActiveDocument.Content myRange.Find.Execute FindText:="Roll Call", Forward:=False If myRange.Find.Found = True Then Selection.TypeParagraph ActiveDocument.Bookmarks.Add Name:="mark" End Sub |
#2
|
||||
|
||||
![]()
The following should do the job
Code:
Sub macro2() Dim myRange As Range Set myRange = ActiveDocument.Content With myRange.Find Do While .Execute(FindText:="Roll Call", MatchCase:=True) 'Find the text myRange.InsertParagraphAfter 'insert a paragraph break after it myRange.End = myRange.End + 1 'move the end of the range beyond the paragraph break myRange.Collapse 0 'Collapse the range to its end ActiveDocument.Bookmarks.Add Name:="mark", Range:=myRange 'add a bookmark at the range myRange.Select 'optionally select it Exit Do 'Stop looking for the text Loop End With End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Thank you, this appears to work as expected
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find Bookmark, move to bookmark, execute code, repeat | raymm3852 | Word VBA | 10 | 04-15-2016 06:21 PM |
![]() |
BayhDole | Word | 2 | 07-21-2015 08:43 PM |
Find last word in paragraph and delete it | Dave T | Word VBA | 3 | 05-21-2015 12:40 AM |
![]() |
dsjk9190 | Word VBA | 2 | 01-22-2015 01:15 AM |
![]() |
LeeFX | Word | 4 | 05-05-2011 05:53 PM |