+ Reply to Thread
Results 1 to 3 of 3

change code from filesearch to FSO and Dir

  1. #1
    Registered User
    Join Date
    03-18-2010
    Location
    Alkmaar, Holland
    MS-Off Ver
    Excel 2003
    Posts
    3

    change code from filesearch to FSO and Dir

    Hello everybody.

    i did write some code in VBA reading all files with fitting a wildcard format from a given directory and all subdirectorys and place the found files and path in an excel sheet.

    I used herefore the Application.FIleSearch object.
    The problem is that this sometimes not working with Windows 7 or is not always recognizing "zip" files.

    I Googled on internet and learned that it will be better to use FileSystemObject and Dir to do the job, because FileSearch is not allways supported by the system.

    I did try to translate the code, but couldn't work it out.

    How to translate the next code in the other FSO and Dir format?

    Please Login or Register  to view this content.

    wereby WildC is the wildcard to search for and Filepad is the starting directory to look from including all subdirectorys?

    Any help would be preciated.
    Last edited by canedje; 03-18-2010 at 07:35 AM.

  2. #2
    Registered User
    Join Date
    03-18-2010
    Location
    Alkmaar, Holland
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: change code from filesearch to FSO and Dir

    I did found the next code somewhere at this forum. (a littlebit modified by myself)
    Doing almost the job.

    Only thing missing is the possibility to add an search wildcard for the files to display.
    For example "*.xls" as a wildcard is showing only the excel files instead of all files like the code below.

    Is this code easy to change to my wishes and add a wildcard option?




    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-18-2010
    Location
    Alkmaar, Holland
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: change code from filesearch to FSO and Dir

    I installed the last code from above in the total program I wrote.
    It works fine.

    I only do need a function returning false or true if an string is fitting with an wildcard.
    for example:

    function compare(wildcard as string, filename as string) as boolean

    Function compare is true when: wildcard is "*.xls" and filename is "test.xls"
    Function compare is false when: wildcard is "*.doc" and filename is "test.xls"
    etc.

    can anybody help with some code? Or give hints where to find an example?
    Last edited by canedje; 03-18-2010 at 01:35 PM.

+ Reply to 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