Results 1 to 3 of 3

Copying filepath onto a cell

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Copying filepath onto a cell

    What I have:

    Used a code and copied the filenames of the files from a particular folder onto an excel sheet
    Code used :
    Private Sub GetFileNames_click()
    
        Dim xRow As Long
        Dim xDirect$, xFname$, InitialFoldr$
    
        InitialFoldr$ = "G:\"    '<<< Startup folder to begin searching from
    
        With Application.FileDialog(msoFileDialogFolderPicker)
            .InitialFileName = Application.DefaultFilePath & "\"
            .Title = "Please select a folder to list Files from"
            .InitialFileName = InitialFoldr$
            .Show
                 If .SelectedItems.Count <> 0 Then
                xDirect$ = .SelectedItems(1) & "\"
                xFname$ = Dir(xDirect$, 7)
                Do While xFname$ <> ""
             
                Dim val2 As String
                val2 = ComboBox1.RowSource
                If val2 = ("Couplings") Then
                
                ActiveWorkbook.Worksheets("Falk gear Box").Activate
        Range("B4").Select
                
                '            Worksheets("Falk gear Box").Range("C4").Select = ActiveCell
                
             
                    ActiveCell.Offset(xRow) = xFname$
                    xRow = xRow + 1
                    xFname$ = Dir
                        End If
                Loop
                      
             End If
        End With
        
        
    End Sub
    Courtesy : above code is a modified version of a code got from the net.



    What I need :


    The above code only copies the file names onto column 2. I wanted help in finding a way as to how to display the file path from where the above file names were taken ?


    Any help is much appreciated...


    Thanks in advance
    Last edited by subbby; 09-01-2012 at 11:44 AM. Reason: solved

Thread Information

Users Browsing this Thread

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

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