Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
spreadsheet part and part without grid lines | Excel Discussion (Misc queries) | |||
Search/Match/Find ANY part of string to ANY part of Cell Value | Excel Worksheet Functions | |||
Cell("filename") doesn't update to new filename when do save as. | Excel Worksheet Functions | |||
set filename to <filename-date on open | Excel Worksheet Functions | |||
Copying Part of a row down part of a column | Excel Discussion (Misc queries) |