Closed Thread
Results 1 to 6 of 6

List files in folder

  1. #1
    Registered User
    Join Date
    05-28-2008
    Posts
    3

    List files in folder

    Greetings one and all
    Everyone must start somewhere so I choose to start on this old post since it happens to applicable to my stumbling block. I too needed to list all the files, folders and subfolders in a given directory and was able to find a pair of macros on the web which gave me most of what I needed (plagiarism is a wonderful thing) and then with a bunch of modification I came up with the macros below. My problem is in the second macro (ListFilesInFolder). I have been unable to get Microsoft to give up the file "owner" (Person who created the file) to my spreadsheet. I can see it just fine when I am in that folder, I just can't get it into my excel file. The line that is giving me the trouble is:

    Please Login or Register  to view this content.
    Does anyone know what I need to do to make this work?
    Randy P



    Here are the macros:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by VBA Noob; 05-29-2008 at 05:59 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello scubajon,

    I modified your macro ListFilesInFolder to include the call to the new macro GetFileOwner. The macros now use late binding. This allows them to run directly without having to remember to set a project reference to the object libraries. It will run a little slower this way, but simplifies interoperability. The problem with plagiarism is you never know if the information is correct.

    ListFilesInFolder Macro
    Please Login or Register  to view this content.
    GetFileOwner Macro
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-28-2008
    Posts
    3
    Thanks Leith
    It will be a couple days before I can get back to this project but I look forward to implementing your code.

    Randy Pedersen
    Boeing/Everett

  4. #4
    Registered User
    Join Date
    05-28-2008
    Posts
    3
    Leith
    I put it in place, ran it and with one minor modification, it worked great! I had to change the objFolderItem from "8" to "9". That's an easy change. Thank you again for your help.
    Randy

  5. #5
    Registered User
    Join Date
    04-09-2015
    Location
    England, Planet Earth
    MS-Off Ver
    2007
    Posts
    3

    Re: List files in folder

    Leith,

    how would I modidy this so that it only lists excel files rather than all files, and it then cleans out all files which don't contain a certain phrase?

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: List files in folder

    Welcome to the forum. Unfortunately:

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

Closed Thread

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