+ Reply to Thread
Results 1 to 16 of 16

Search for file names in main folder and its sub folders

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Search for file names in main folder and its sub folders

    Hello everyone
    I created main folder named "Main Folder" and inside that main folder I created sub folders
    Next to the main folder there is the workbook which I desire to be the Search Workbook for file names in the main folder and the sub folders
    Using input box for search..

    For example : I would type "Excel" in the input box and the expected output would be the sub folder name in column A and the name of the file in column B ...
    No case sensitive (Excel - excel - EXCEL ...) all instances should be included in the search process ..
    Another point the word may be implemented (I mean may be for example the word Excel existed withing another word (ExcelForum) ) this is also to be included in the search process
    I attached expected results for the word "Excel" to illustrate the issue
    Thanks advanced
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    Any help with this topic please?

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

    Re: Search for file names in main folder and its sub folders

    Hello YasserKhalil,

    In the attached workbook, I have added a button on "Sheet1" to call the macro "ListFilesTest". This will match the file names either partially or fully without regard to case.

    Please Login or Register  to view this content.
    Macro Called by the r Command Button
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    Mr. Leith Ross
    Really really amazing & fascinating code
    I'm very admired of this wonderful code
    Thanks a lot .. Thank you very very much
    I appreciate your great help

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    Sorry for disturbing you again
    If possible I need to create hyperlinks to the results .. as in fact I have thousands of files and it would be time saving if I had hyperlinks to the search results
    Thanks advanced

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

    Re: Search for file names in main folder and its sub folders

    Hello YasserKhalil,

    Do you want the output to appear same same but have it be a hyperlink to the folder and a hyperlink to the file?

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    Thanks for reply
    I need to create hyperlink to the file (In column B) .. as it would be very useful to click the file name in column B and the code navigate directly to the file with one click

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

    Re: Search for file names in main folder and its sub folders

    Hello YasserKhalil,

    This version of the code and the workbook add a hyperlink to the files.

    Macro to List Files and Add Hyperlinks
    Please Login or Register  to view this content.
    Macro called by the Button
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    Great and wonderful
    That's fascinating code
    Just last point ... I need to disable the alert related to opening the file ..
    I tried to use application.displayalerts=false but didn't work for me

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

    Re: Search for file names in main folder and its sub folders

    Hello YasserKhalil,

    If the alert is about the workbook containing macros, it is part of the security settings and can not be overridden.

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    It's a Microsoft Office message in title
    'Opening .......(full file path) ...
    Some files can contain viruses or otherwise be harmful to your computer
    It's important to be certain that this file is from a trustworthy source
    Would you like to open this file?'

    and there is two buttons "Ok" and "Cancel"..
    How can I get rid of this alert message?It would be disturbing for me

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

    Re: Search for file names in main folder and its sub folders

    Hello YasserKhalil,

    You will need to add the folder path to "Trusted Locations" in your workbook. You can find this under File > Options > Trust Center > Trust Center Settings... > Trusted Locations

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    I followed the steps and I still got the alert message ..even if I checked the option of "Trust subfolders"

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

    Re: Search for file names in main folder and its sub folders

    Hello YasserKhalil,

    It looks like Office's security does not allow this message to be suppressed for hyperlinks.

  15. #15
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    Thanks a lot Mr. Leith
    I tried to search to solve this problem and I found some solutions which rely on the registry edit ..I tried a lot but all didnot succeed to bypass this alert
    Hope to find solution to this problem
    Thank you very much for great help in this topic

  16. #16
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Search for file names in main folder and its sub folders

    May I post a new thread for my problem with hyperlinks?
    This is time-consuming because of this alert message

+ 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: 27
    Last Post: 06-15-2016, 01:05 PM
  2. Create FOLDER in subfoldesr and move folders with specific names into FOLDER
    By Amarjeet Singh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2015, 09:46 AM
  3. Macro to search files names and sub-folders
    By sambo24 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2015, 10:18 AM
  4. Replies: 0
    Last Post: 05-26-2014, 07:47 PM
  5. Macro to rename photos in a main folder's subfolders to subfolder names
    By Spardante in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2014, 11:41 PM
  6. Improvement - Option To Nest Folders as Sub Folder Under a Main Folder / Heading
    By :) Sixthsense :) in forum Suggestions for Improvement
    Replies: 4
    Last Post: 01-28-2013, 07:09 AM
  7. [SOLVED] Loop through all sub-folders of a main folder and rename sheet same as workbook name
    By sans in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-11-2012, 02:01 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