![]() |
#1
|
|||
|
|||
![]()
I found a Word Macro from the Internet to find text, select it and then add as bookmark. I am trying to modify to fit for my application. I wish the Macro can find and select the text like follows:
The paragraphs I want the Macro to select (From the word "CEO" to the last word "together"): CEO: Today is the first day...... Over the years...... We will work in a.....together. Then select the above paragraphs and add as bookmark. How to edit the Macro code to do that? Your help would be greatly appreciated. Sub addbkmark() Dim myRange As Range Set myRange = ActiveDocument.Content With myRange.Find Do While .Execute(FindText:="XXX", 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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to insert different sets of text at bookmark depending on sequence of selected check boxes | chipper09 | Word VBA | 0 | 06-21-2018 01:49 PM |
Macro to transfer data from Word to another Word document with bookmark | Jovan Yong | Word VBA | 3 | 04-17-2018 04:27 AM |
macro to save as pdf with name from bookmark | pamtupac | Word VBA | 3 | 06-06-2017 08:23 PM |
![]() |
tomsrv | Word VBA | 13 | 08-24-2016 02:26 AM |
![]() |
skarden | Word | 1 | 12-12-2011 10:39 PM |