Workbooks.open using wildcard for folder name

  • Help! I have a macro where I am opening an excel workbook from a network drive and coping the contents of a sheet to a sheet in my active workbook. Today I discovered that the folder name where that workbook will be located has the possibility of changing from time to time. This is because the folder name contains the revision level of the file (third line in example below).

    Can I use a wildcard in my call out?


    Currently my code is this:




    Thanks.

    Edited once, last by royUK: Add Code Tags ().

  • Welcome to Ozgrid, please take the time to read the Forum Rules so that you use the Forum correctly. I have added Code Tags this time.


    You need to add a browse for file into the code. I doubt if Excel will find the folder any other way.

  • Thanks for the update to the post. I am not sure how to do what you are suggesting. My current code is doing what I need if the file name stays as is, but it will change at some point, and I need to account for that.

  • Something like this


  • Thanks Roy. I am looking to do this without the user having to input the file path.


    Thought of other info that might be helpful:

    The xlsx file will always be in the same folder name (R:\Masters\777\Software\7770238 REV ?) only the ? will change.

    There will never be two 7770238 REV ? folders located in this directory. The 7770238 REV B folder will replace the 7770238 REV A.

    The xlsx file within this folder will always be named the same regardless of the revision.

    The xlsx file is the only file in this folder.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!