![]() |
|
#1
|
|||
|
|||
![]()
The script below uses RegEx to find and replace within a Word selection. The problem is that many times, depending how the text is formatted, it changes this formatting style.
How can I search and replace (using RegEx) while keeping everything else intact? Thank you! Alex Code:
Dim RegEx As Object Set RegEx = CreateObject("vbscript.RegExp") With RegEx .pattern = "old_text" .Global = True Selection.Text = .replace(Selection.Text, "new_text") End With |
#2
|
|||
|
|||
![]()
Ok, in the meantime I managed to find a solution using wildcards.
Alex |
#3
|
||||
|
||||
![]()
Regex has no regard to formatting.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ksor | Word | 4 | 11-04-2019 11:35 AM |
![]() |
mr_gray | Word | 3 | 10-02-2015 05:53 AM |
![]() |
Carolin | Word VBA | 3 | 12-14-2014 04:01 AM |
How to extract text from a cell and preserve special formatting? | epid011 | Word VBA | 2 | 04-04-2014 04:54 PM |
![]() |
StarWeaver | Excel | 1 | 03-02-2010 01:41 PM |