Results 1 to 20 of 20

Auto link from excel to folder's files

Threaded View

  1. #18
    Registered User
    Join Date
    09-01-2018
    Location
    USA
    MS-Off Ver
    365
    Posts
    96

    Re: Auto link from excel to folder's files

    Use macro below - just remainder anything in active sheet in the first 4 columns ( A-D) will be deleted before new data is added
    Private Sub Workbook_Open()
    Dim xFSO As Object
        Dim xFolder As Object
        Dim xFile As Object
        Dim xPath As String
        Dim i As Long
    
    ActiveSheet.Range(Cells(1, 1), Cells(Rows.Count, 4)).ClearContents
    ActiveSheet.Range(Cells(1, 1), Cells(Rows.Count, 4)).ClearFormats
    
          xPath = "C:\Users\xxxx\Desktop\New folder"
    
        Set xFSO = CreateObject("Scripting.FileSystemObject")
        Set xFolder = xFSO.GetFolder(xPath)
        For Each xFile In xFolder.Files
            i = i + 1
    
            ActiveSheet.Hyperlinks.Add Cells(i + 1, 1), xFile.Path, , , xFile.Name
            ActiveSheet.Cells(i + 1, 2).Value = xFile.DateLastModified
            ActiveSheet.Cells(i + 1, 3).Value = xFile.DateCreated
            ActiveSheet.Cells(i + 1, 4).Value = xFile.DateLastAccessed
        Next
    
            With CreateObject("scripting.filesystemobject")
            For Each xFolder In .GetFolder(xPath).SubFolders
            ActiveSheet.Hyperlinks.Add Anchor:=Cells(i + 3, 1), _
                     Address:=xPath & Application.PathSeparator & xFolder.Name, _
                     TextToDisplay:=xFolder.Name
                        Cells(i + 3, 1).Font.Bold = True
                        Cells(i + 3, 1).Interior.ColorIndex = 8
            ActiveSheet.Cells(i + 3, 2).Value = xFolder.DateLastModified
            ActiveSheet.Cells(i + 3, 3).Value = xFolder.DateCreated
            ActiveSheet.Cells(i + 3, 4).Value = xFolder.DateLastAccessed
    
            i = i + 1
    
        Next
        End With
    
    Range("A1").FormulaR1C1 = "Name"
        Range("B1").FormulaR1C1 = "DateLastModified"
       Range("C1").FormulaR1C1 = "DateCreated"
        Range("D1").FormulaR1C1 = "DateLastAccessed"
        Columns("A:D").EntireColumn.AutoFit
    End Sub
    Last edited by AC PORTA VIA; 11-06-2020 at 09:45 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 05-17-2018, 01:47 PM
  2. Replies: 3
    Last Post: 01-29-2018, 11:34 AM
  3. VBA to Auto Zip the Folder or Files
    By mvinay in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-28-2014, 05:20 AM
  4. Replies: 1
    Last Post: 09-22-2010, 11:00 AM
  5. Create automatic link to files in same folder.
    By Little Master in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-26-2009, 11:45 AM
  6. auto open excel files in the folder
    By ccs1981 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2009, 02:19 AM
  7. auto open the excel files in the folder
    By ccs1981 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2008, 04:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1