Finding Excel files with external links

JBITTNER3260

New Member
Joined
Apr 9, 2018
Messages
1
All,
My administrative department has a bunch of Excel files with links to other Excel files in a variety of network folders. They want (need) to move the files to a new server. I'm thinking that if they move to the new server, all of the links will be severed and they'll need to re-link them manually.

I have two questions:
  1. Is there a way to survey the network file structure and determine the excel files that contain external links?
  2. Is there a way to "automatically" update the external link paths so that the links work after moving to the new server?

Thanks in advance,

JB
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi JB,
if the files are moved from e.g. C:\ThisDirectory\ to N:\ThatDirectory\ , that will probably break the links between files. What you could do is create a macro that loops through the directories and opens every Excel file it encounters, modifies the links and closes/saves the file. I don't know how many files you're talking about, but that might take a while. On the other hand, that would save the users quite a lot of manual work&mistakes :).
I don't know how your VBA is, but it could be worth hiring somebody for the job if it's lots of files and/or teaching yourself VBA. Find some code added that can list all files in a directory and directories below it (all levels).
Cheers,
Koen

-------
Based on https://stackoverflow.com/a/22646086/4552016
Code:
Public Sub NonRecursiveMethod()
    Dim fso, oFolder, oSubfolder, oFile, queue As Collection
    Dim ResultArray() As String
    Dim n As Long
    
    Set ResultSheet = Worksheets("MySheetName")
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set queue = New Collection
    queue.Add fso.GetFolder("C:\Users\MyUser\MyDirectory\") 'obviously replace

    n = 1
    ReDim Preserve ResultArray(1 To 3, 1 To n)
    ResultArray(1, n) = "Path"
    ResultArray(2, n) = "FileName"
    ResultArray(3, n) = "LastModified"
    
    Do While queue.Count > 0
        Set oFolder = queue(1)
        queue.Remove 1 'dequeue
        '...insert any folder processing code here...
        For Each oSubfolder In oFolder.SubFolders
            queue.Add oSubfolder 'enqueue
        Next oSubfolder
        For Each oFile In oFolder.Files
            '...insert any file processing code here...
            If InStr(oFile.Name, ".xls") Then
                n = n + 1
                ReDim Preserve ResultArray(1 To 3, 1 To n)
                ResultArray(1, n) = oFolder.Path
                ResultArray(2, n) = oFile.Name
                ResultArray(3, n) = oFile.DateLastModified
                'Debug.Print oFolder.Path, oFile.Name, oFile.DateLastModified
            End If
        Next oFile
    Loop

    ResultSheet.Range("A1").Resize(UBound(ResultArray, 2), UBound(ResultArray, 1)).Value = Application.Transpose(ResultArray)
    MsgBox "Found " & n - 1 & " files", vbOKOnly
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top