![]() |
Find File By Name
Hello Programmers, Is it possible to open a particular file *by name *regardless of what folder it may be in on C drive? Example filename Store Inventory.xls somewhere on C drive The reason is because the file name stays the same, however the file moves to a different folder with the current month's name. So to keep from changing the destination on the macro each month, I just want the code to find the file, by its name. Thanks, EMoe -- EMoe ------------------------------------------------------------------------ EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183 View this thread: http://www.excelforum.com/showthread...hreadid=493047 |
Find File By Name
EMoe,
It would be better if you knew the folder name based on the current date, along the lines of Workbooks.Open "C:\Folder 1\" & Format(Now(),"mmmmyy") & "\Store Inventory.xls" Otherwise, you could use code like this With Application.FileSearch .NewSearch .LookIn = "C:\" .SearchSubFolders = True .FileName = "Store Inventory.xls" If .Execute 0 Then Workbooks.Open .FoundFiles(1) End If End With which will work as long as there is only one Store Inventory.xls on your C drive. HTH, Bernie MS Excel MVP "EMoe" wrote in message ... Hello Programmers, Is it possible to open a particular file *by name *regardless of what folder it may be in on C drive? Example filename Store Inventory.xls somewhere on C drive The reason is because the file name stays the same, however the file moves to a different folder with the current month's name. So to keep from changing the destination on the macro each month, I just want the code to find the file, by its name. Thanks, EMoe -- EMoe ------------------------------------------------------------------------ EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183 View this thread: http://www.excelforum.com/showthread...hreadid=493047 |
Find File By Name
Thanks Bernie, I give it a shot! EMoe -- EMoe ------------------------------------------------------------------------ EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183 View this thread: http://www.excelforum.com/showthread...hreadid=493047 |
All times are GMT +1. The time now is 12:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com