![]() |
|
|
|
#1
|
||||
|
||||
|
You could use something along the lines of: Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = InputBox("What is the Text to Find")
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found
With .Duplicate
.Collapse wdCollapseStart
.Text = "Prefix "
.Font.Italic = True
End With
With .Duplicate
.Collapse wdCollapseEnd
.Text = " Suffix"
.Font.Bold = True
End With
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Thanks but I can't quite get it to work as I want it to. Perhaps I'd better explain what I want to do. I have something like this:
Random line that stays as it is. TRIGGER LINE This text to be made uppercase Random line that stays as it is. Random line that stays as it is. Random line that stays as it is. TRIGGER LINE This text to be made uppercase Random line that stays as it is. Random line that stays as it is. Random line that stays as it is. I have a small bit of code from recording a macro that goes down one line from the TRIGGER LINE, selects the line where the cursor now is and makes it uppercase. The problem is I have 3,000-odd instances of the TRIGGER LINE so I need to automate it. The code I have to do this is: Selection.MoveDown Unit:=wdLine, Count:=1 Selection.HomeKey Unit:=wdLine Selection.EndKey Unit:=wdLine, Extend:=wdExtend Selection.Font.AllCaps = True Selection.HomeKey Unit:=wdLine I just need to be able to have something that searches for each instance of the text TRIGGER LINE and then runs my code. It would then move on to the next instance of TRIGGER LINE and repeat until the end of the document. When I tried to put my code in your code it uppercased everything. It wasn't clear to me which part sof your code were interchangeable. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Outlook search not finding recent mail; rebuild ix did nothing | PeterA | Outlook | 0 | 01-19-2017 12:27 AM |
Need some vba code to search a word document an replace it if len = 3
|
Belleke | Word VBA | 3 | 10-24-2016 01:00 AM |
Finding more than one word using "find" or using a vba code
|
capitala | Word VBA | 1 | 02-03-2014 06:45 PM |
Outlook 2010 Search not finding all items
|
gdrunner | Outlook | 2 | 03-10-2013 06:48 PM |
| Outlook 2010 search not finding everything | rexracer | Outlook | 5 | 07-21-2011 02:31 AM |