SuperKrishna
New Member
We've recently switch drive letters and I've written some code to open files, search and replace drive letters then save. What I would like to add is the ability to replace drive letters in the "Edit Links" section for all external links in the file.
I have a range, starting in K12 that contains a list of pathfilenames that Excel will sequentially open then perform a search and replace. Before the ActiveWorkbook.Save, I would like to edit all links and switch from the previous path "S:Act" to the new path "X:Act". Any insight would be appreciated.
[/pre]
[EndCode]#################################
I have a range, starting in K12 that contains a list of pathfilenames that Excel will sequentially open then perform a search and replace. Before the ActiveWorkbook.Save, I would like to edit all links and switch from the previous path "S:Act" to the new path "X:Act". Any insight would be appreciated.
Code:
#################################
[pre][code]Sub UpdateLinks()
Dim ws As Worksheet
On Error Resume Next
Application.DisplayAlerts = False
Range("K12").Select
Do While Not (IsNull(ActiveCell.Value))
Workbooks.Open Filename:=ActiveCell.Value
Cells.Replace What:=Range("strOldPath").Value, _
Replacement:=Range("strNewPath").Value, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
ActiveWorkbook.Save
ActiveWindow.Close
ActiveCell.Offset(1, 0).Select
Loop
Application.DisplayAlerts = True
End Sub
[EndCode]#################################