Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening files with a part Name 1

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Dear All,

Is it possible to open a file name by matching part of the name in the file name, have a files called all_bti_summary.csv each day I receive this file and lots of other files to a Drive H:\, I need to move this file to a different drive, the problem I have is the file all_bti_summary.csv can and always has numbers on the front, the numbers change daily, and vary all the time, is there a way to open the file just by finding the "all_bti_summary" part of the file. I know how to open the file and edit it and then save it to disk with the same file name each time, I am not sure how to open a file name based on a part name.

Can someone help on this thanks.

Regards


 
Rob,

I've done some experimenting and here is what I found (using Excel which I'm assuming is what you're also using):

To open the csv file you can use Workbooks.OpenText

You can supply a filename that includes wildcard characters; e.g. ? or *

This will open the first matching file. If no mathcing files an error occurs. Using your filename, here is an example procedure:

Code:
Sub OpenCSV()
Dim FName As String

  FName = "C:\*_all_bti_summary.csv"
  Workbooks.OpenText FileName:=FName, DataType:=xlDelimited, Comma:=True

End Sub

HTH
M. Smith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top