![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 40
|
I currently have a button set with the following code:
I need to try and limit the search so that it does not open any file including 'CSJ' in the title that starts with an 'x'? Can anyone help? Private Sub CommandButton1_Click() Dim lngLoop As Long With Application.FileSearch .NewSearch .LookIn = "e:intasysreports" .SearchSubFolders = False .FileName = "*csj*" .FileType = msoFileTypeAllFiles If .Execute > 0 Then For lngLoop = 1 To .FoundFiles.Count Workbooks.OpenText FileName:=.FoundFiles(lngLoop), DataType:=xlDelimited, other:=True, otherchar:="|" Next End If End With End Sub |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: May 2002
Posts: 63
|
You could try embedding another loop. First save the file name to a variable, them run one or more tests on it. If it passes, then go ahead and have your way with it.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|