View Single Post
 
Old 03-16-2025, 08:06 AM
Jakster Jakster is offline Windows 11 Office 2021
Novice
 
Join Date: Mar 2025
Posts: 6
Jakster is on a distinguished road
Default

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.
Reply With Quote