+ Reply to Thread
Results 1 to 2 of 2

File name extraction w/hyperlinks no duplicates.

  1. #1
    Registered User
    Join Date
    04-14-2013
    Location
    Ontario
    MS-Off Ver
    Excel 2010
    Posts
    1

    File name extraction w/hyperlinks no duplicates.

    Hey all, new to forum posting but here we go. I would like to be able to extract all file names from a given folder to a spread sheet that would also create hyperlinks to the files extracted. Also if possible when the script is run for a second time, lets say to update that it would only add new files to the spread sheet. I have tried a macro script file that allows you to select files and it extracts the file names but have no idea as to get it to hyperlink said files and not duplicate pre-existing files. I would appreciate any insight.

    Here is a copy of the macro I am currently using.

    Option Explicit

    Private Sub CommandButton1_Click()
    Dim rngSave As Range
    Dim lngCount As Long
    Dim strPathFile As String
    Dim strFname As String
    Dim intLastDiv As Integer
    Dim n As Integer

    On Error GoTo ErrHnd

    With ActiveSheet
    'find the last used cell in column A
    Set rngSave = .Range("A65534").End(xlUp)

    ' Open the file dialog
    With Application.FileDialog(msoFileDialogFilePicker)
    .AllowMultiSelect = True
    .Show
    'Copy all path/filenames into column A
    For lngCount = 1 To .SelectedItems.Count
    strPathFile = .SelectedItems(lngCount)
    'find last "/" in path/filename
    intLastDiv = 0
    For n = 1 To Len(strPathFile)
    If Mid(strPathFile, n, 1) = "\" Then
    intLastDiv = n
    End If
    Next n
    rngSave.Offset(lngCount - 1, 0) = strPathFile
    'split filename from path
    'save path in column A
    rngSave.Offset(lngCount - 1, 0).Value = Left(strPathFile, intLastDiv)
    'save filename in column B
    rngSave.Offset(lngCount - 1, 1).Value = Right(strPathFile, Len(strPathFile) - intLastDiv)
    Next lngCount
    End With
    'set column widths to fit
    .Range("A1:B" & Format(rngSave.Row + lngCount, "##0")).Columns.AutoFit
    End With
    Exit Sub

    'error handler
    ErrHnd:
    Err.Clear
    End Sub

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: File name extraction w/hyperlinks no duplicates.

    Hi,

    Please Login or Register  to view this content.
    Last edited by tehneXus; 04-14-2013 at 08:04 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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