View Single Post
 
Old 05-11-2017, 09:05 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I take it that we can assume this is a hyperlink field, in which case the following macro will work (replace the paths etc as appropriate) when used as a custom process with
http://www.gmayor.com/document_batch_processes.htm which will perform the file/folder handling.
Code:
Function ReplaceLink(oDoc As Document)
    On Error GoTo err_Handler
    Dim oRng As Range
    Dim hLink As Hyperlink
    Set oDoc = ActiveDocument
    For Each hLink In oDoc.Hyperlinks
        If hLink.Address = "C:\Path\TargetWorkbook.xlsx" Then
            With hLink
                .Address = "C:\Path\Replacement.xlsx"
                .TextToDisplay = "C:\Path\Replacement.xlsx"
                .ScreenTip = "Click to open workbook"
                .Target = "C:\Path\Replacement.xlsx"
            End With
        End If
    Next hLink
    ReplaceLink = True
lbl_Exit:
    Exit Function
err_Handler:
    ReplaceLink = False
    Err.Clear
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote