Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Get a part of a filename

Sorry Bernie I post the response to the wrong box

There is only one file that begins with "Test"
The rest of the name can be a date or anything else

"Bernie Deitrick" schreef in bericht
...
Peter,

And if there is a file "Test 07-11-03.xls" AND the file "Test
07-12-03.xls", what do you want to do? Open them both?

Bernie
MS Excel MVP

"Peter Pantus" wrote in message
...
Hi All

I'am trying to get a part of a filename
I don't know how to do this - must I work with jokers!!
Example: Filename is "Test 07-11-03.xls"
I want, whitin VBA, only type te word "Test" and then the result

must be
that the file "Test 07-11-03.xls" opens

Thanks for any answer
Peter P






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Get a part of a filename

Peter,

In that case, try something like:

Dim myFName As String
myFName = Application.InputBox("Enter the first four letters...")

With Application.FileSearch
.NewSearch
.LookIn = "C:\Excel\DeleteThese"
.SearchSubFolders = False
.Filename = myFName & "*"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
Workbooks.Open .FoundFiles(1)
Else
MsgBox "There was no file found."
End If
End With

HTH,
Bernie
MS Excel MVP

"Peter Pantus" wrote in message
...
Sorry Bernie I post the response to the wrong box

There is only one file that begins with "Test"
The rest of the name can be a date or anything else

"Bernie Deitrick" schreef in bericht
...
Peter,

And if there is a file "Test 07-11-03.xls" AND the file "Test
07-12-03.xls", what do you want to do? Open them both?

Bernie
MS Excel MVP

"Peter Pantus" wrote in message
...
Hi All

I'am trying to get a part of a filename
I don't know how to do this - must I work with jokers!!
Example: Filename is "Test 07-11-03.xls"
I want, whitin VBA, only type te word "Test" and then the result

must be
that the file "Test 07-11-03.xls" opens

Thanks for any answer
Peter P








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Get a part of a filename

Thanks Bernie
That is acced what I'am looking for

Peter P.


"Bernie Deitrick" schreef in bericht
...
Peter,

In that case, try something like:

Dim myFName As String
myFName = Application.InputBox("Enter the first four letters...")

With Application.FileSearch
.NewSearch
.LookIn = "C:\Excel\DeleteThese"
.SearchSubFolders = False
.Filename = myFName & "*"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
Workbooks.Open .FoundFiles(1)
Else
MsgBox "There was no file found."
End If
End With

HTH,
Bernie
MS Excel MVP

"Peter Pantus" wrote in message
...
Sorry Bernie I post the response to the wrong box

There is only one file that begins with "Test"
The rest of the name can be a date or anything else

"Bernie Deitrick" schreef in bericht
...
Peter,

And if there is a file "Test 07-11-03.xls" AND the file "Test
07-12-03.xls", what do you want to do? Open them both?

Bernie
MS Excel MVP

"Peter Pantus" wrote in message
...
Hi All

I'am trying to get a part of a filename
I don't know how to do this - must I work with jokers!!
Example: Filename is "Test 07-11-03.xls"
I want, whitin VBA, only type te word "Test" and then the result
must be
that the file "Test 07-11-03.xls" opens

Thanks for any answer
Peter P










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
spreadsheet part and part without grid lines jan Excel Discussion (Misc queries) 2 April 26th 10 11:27 PM
Search/Match/Find ANY part of string to ANY part of Cell Value TWhizTom Excel Worksheet Functions 0 July 21st 08 08:16 PM
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
Copying Part of a row down part of a column Not Excelling Excel Discussion (Misc queries) 3 January 6th 06 11:58 PM


All times are GMT +1. The time now is 08:40 AM.

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

About Us

"It's about Microsoft Excel"