![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#2
|
|||
|
|||
|
Just an update.... I think I may have found a way to make it work... I have used the following code (again, found online and modified) which seems to done the trick.
Code:
Sub ReplaceFields(ByVal rngStory As Word.Range, ByVal strSearch As String, ByVal strReplace As String)
Dim oFld As Field
Dim oRng As Range
For Each oFld In ActiveDocument.Fields
Set oRng = oFld.Code
If InStr(1, oRng.Text, strSearch) > 0 Then
oRng.MoveStart wdCharacter, -1
oRng.Collapse
oRng.InsertAfter strReplace
oFld.Delete
End If
Next oFld
lbl_Exit:
Set oFld = Nothing
Set oRng = Nothing
Exit Sub
End Sub
Last edited by Jakster; 03-16-2025 at 06:02 PM. |
| Tags |
| mailmerge, ms-word, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Plain text help with returns - looking for marker to use when converting to plain text
|
redzan | Word | 1 | 04-18-2017 06:17 PM |
| Macro to keep formatted form fields after mail merge or replace text with formatted form fields | jer85 | Word VBA | 2 | 04-05-2015 10:00 PM |
| Searhc for Hyperlinked Word and replace with plain text or nothing | somniloquist | Word | 3 | 10-04-2011 02:33 AM |
Replace all occurrences of one merge field with plain text
|
blankenthorst | Mail Merge | 5 | 07-01-2011 05:18 AM |
| Replace All with plain text containing subscript | DeaducK | Word | 0 | 06-24-2010 08:16 PM |