+ Reply to Thread
Results 1 to 4 of 4

Getting the file location with file name

  1. #1
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Agra
    MS-Off Ver
    Office 2010
    Posts
    241

    Getting the file location with file name

    Hi,

    we have a folder with the name of "Test", where we have some files

    1. test.pdf
    2. test.jpeg
    3. test.excl

    how can we get the path with file name

    Example
    D:\owork\med\fin\test.pdf
    D:\owork\med\fin\test.jpeg
    D:\owork\med\fin\test.excel

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: Getting the file location with file name

    Bob Phillips shows how to use the CELL function on his website here:

    http://www.xldynamic.com/source/xld.xlFAQ0002.html

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Agra
    MS-Off Ver
    Office 2010
    Posts
    241

    Re: Getting the file location with file name

    Tried but not worked, dont know what is wrong

  4. #4
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Agra
    MS-Off Ver
    Office 2010
    Posts
    241

    Re: Getting the file location with file name

    got the solution



    got the solution

    Sub FileDetails()
    Dim objFSO As Object
    Dim objFolder As Object
    Dim objFile As Object
    Dim i As Integer

    'Create an instance of the FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Get the folder object
    Set objFolder = objFSO.GetFolder("C:\Users\Me\Desktop\Temp(5)")
    i = 1
    'loops through each file in the directory and prints their names and path
    For Each objFile In objFolder.Files
    'print file name
    Cells(i + 1, 5) = objFile.Name
    'print file path
    Cells(i + 1, 5) = objFile.Path
    i = i + 1
    Next objFile
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 03-25-2020, 11:14 AM
  2. [SOLVED] To create a file folder in the current workbook location and export the file
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2016, 07:30 AM
  3. [SOLVED] Macro to prompt user to select a file and the selected file should saved in location
    By logesh excel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2015, 03:43 PM
  4. Replies: 14
    Last Post: 08-09-2014, 02:14 AM
  5. Macro to Download csv file from a dynamic date based url to a specified file location
    By srimani202002 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2014, 07:17 AM
  6. Save as macro that specifies file type, file location and takes file name from three cells
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-13-2013, 10:09 PM
  7. Replies: 1
    Last Post: 10-01-2012, 11:46 PM

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