Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I find a file that I save but can't seem to find Marge[_2_] Excel Discussion (Misc queries) 11 January 25th 09 06:27 PM
How do I find a deleted excel file? Or an autosave file? Aladriel Excel Discussion (Misc queries) 10 January 3rd 08 07:46 PM
clicking .XLS file opens Excel 2003 but doesn't find the file Arrow Computer Excel Discussion (Misc queries) 2 August 10th 05 03:51 AM
How do I find a file/spreadsheet that Excel says is Already open but I can't find it? nwtrader8 Excel Discussion (Misc queries) 5 June 21st 05 02:16 PM
Want file title listing as in Excel 5.0 File>Find jeffbro27707 Excel Discussion (Misc queries) 0 April 30th 05 07:31 PM


All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"