![]() |
#7
|
|||
|
|||
![]()
What specifically are you trying to do? If you want to insert a line break before " (about" then:
Code:
Sub ScratchMacro() 'A basic Word Macro coded by Gregory K. Maxey Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find .Text = " (about" If .Execute Then oRng.Characters(1).Delete oRng.InsertBefore Chr(11) End If End With lbl_Exit: Exit Sub End Sub In your existing code, the .Execute is only going return True once because after the first find, oRng IS the found text and the found text is the text you want to find. Type this sentence in a select a word document and then run: Code:
Sub Demo() Dim oRng As Range Set oRng = Selection.Range With oRng.Find .Text = Selection.Text If .Execute Then MsgBox "Found" Else MsgBox "I can't find myself when I AM the defined search range." End If End With lbl_Exit: Exit Sub End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
eduardb | Word | 1 | 08-10-2022 03:17 AM |
Search Word for specific strings and replace with hyperlinks from a list | jlive24 | Word VBA | 2 | 06-26-2022 08:14 PM |
Extracting Specific Text Strings | PWH68 | Word VBA | 6 | 10-08-2019 02:07 AM |
![]() |
ppayaw | Word VBA | 8 | 12-13-2016 08:11 AM |
![]() |
vikrantkale | Word | 1 | 03-28-2011 06:13 PM |