Open Files With Number Extensions

  • Hi,


    I have a workbook that will need data from another which will be located in the same directory. I need to open this workbook however the filename will be imported daily and be different each time (i.e. 010707.xls, 010807.xls, etc.) The only two files residing in the directory will be the active file and the one that needs to be opened.


    Is there a way to assign a variable for the 010707? Currently I have the following and need to manually modify the file name:


    Code
    Workbooks.Open Filename:="C:\My Documents\template\010707.xls"


    Thanks for any help on this,


    Keith

  • Re: Open Files With Number Extensions


    I am guessing that the file name is the date the file was created (or poertains to). If this is correct, is it always the previous day, two days prior etc. If so, you can create the file name based on the current date (minus 1, 2, etc) and use the text value of that. and append the .xls to the end of it.

  • Re: Open Files With Number Extensions


    Actually they are date driven but will be at least a month behind and not always in sequence when we receive the files so I need some sort of variable that will open any excel file not already open within that directory.


    (thanks for the quick reply)

  • Re: Open Files With Number Extensions


    Keith


    If all you want to do is open all the files in a direcory why do you need the names?


    I would suggest you tak a look at Application.FileSearch and/or the FileSystemObject.

    Boo!:yikes:

  • Re: Open Files With Number Extensions


    I just want to open the one other file which will be imported into that directory daily.


    It could be 010707.xls, 021607.xls or any other date.


    I guess I just want to avoid having to re-map the macro each time and my VBA skills are pretty abysmal at trying to come up with a variable which would say "open any file with a numeric name".

Participate now!

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