![]() |
|
|
|
#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] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Formatting figures ?? - Preserve formatting of shapes for future use
|
ksor | Word | 4 | 11-04-2019 11:35 AM |
Is it spossible to preserve the original line numbers for reference when editing a document?
|
mr_gray | Word | 3 | 10-02-2015 05:53 AM |
Need macro to merge files in Word and preserve formatting
|
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 |
Cut and paste a range of cells and preserve formatting
|
StarWeaver | Excel | 1 | 03-02-2010 01:41 PM |