J
João Rego
When i use this command button in a pc wint XP and Excel 2003 in English this
query works, when i try in my computer with XP in Portuguese and Excel 2003
in English the results is always "No files found."
Anyone can help-me?
-------------------------------------------------------------------------------------
Sub SearchForFiles()
'Declare a variable to act as a generic counter
Dim lngCount As Long
Application.ScreenUpdating = False ' turn off the screen updating
'Use a With...End With block to reference the
'FileSearch object
Set fs = Application.FileSearch
With fs
'Clear all the parameters of the previous searches.
'This method doesn't clear the LookIn property or
'the SearchFolders collection.
.NewSearch
'Setting the FileType property clears the
'FileTypes collection and sets the first
'item in the collection to the file type
'defined by the FileType property.
.FileType = msoFileTypeExcelWorkbooks
.Filename = "VW*"
'Set up the search to look in all subfolders on the C:\ drive.
.LookIn = "c:\VW"
.SearchSubFolders = True
'Execute the search and test to see if any files
'were found.
valor = .Execute
If valor > 0 Then
'Display the number of files found.
MsgBox "Files found: " & .FoundFiles.Count
'Loop through the list of found files and
'display the path of each one in a message box.
For lngCount = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles.Item(lngCount)
valor = valor + Worksheets("Sheet1").Range("I96").Value
ActiveWorkbook.Close
Next lngCount
Else
MsgBox "No files found."
End If
End With
Application.ScreenUpdating = True ' turn on the screen updating
Worksheets("Sheet1").Range("C6").Value = valor
End Sub
Private Sub CommandButton1_Click()
Call SearchForFiles
End Sub
Private Sub s_Click()
End Sub
query works, when i try in my computer with XP in Portuguese and Excel 2003
in English the results is always "No files found."
Anyone can help-me?
-------------------------------------------------------------------------------------
Sub SearchForFiles()
'Declare a variable to act as a generic counter
Dim lngCount As Long
Application.ScreenUpdating = False ' turn off the screen updating
'Use a With...End With block to reference the
'FileSearch object
Set fs = Application.FileSearch
With fs
'Clear all the parameters of the previous searches.
'This method doesn't clear the LookIn property or
'the SearchFolders collection.
.NewSearch
'Setting the FileType property clears the
'FileTypes collection and sets the first
'item in the collection to the file type
'defined by the FileType property.
.FileType = msoFileTypeExcelWorkbooks
.Filename = "VW*"
'Set up the search to look in all subfolders on the C:\ drive.
.LookIn = "c:\VW"
.SearchSubFolders = True
'Execute the search and test to see if any files
'were found.
valor = .Execute
If valor > 0 Then
'Display the number of files found.
MsgBox "Files found: " & .FoundFiles.Count
'Loop through the list of found files and
'display the path of each one in a message box.
For lngCount = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles.Item(lngCount)
valor = valor + Worksheets("Sheet1").Range("I96").Value
ActiveWorkbook.Close
Next lngCount
Else
MsgBox "No files found."
End If
End With
Application.ScreenUpdating = True ' turn on the screen updating
Worksheets("Sheet1").Range("C6").Value = valor
End Sub
Private Sub CommandButton1_Click()
Call SearchForFiles
End Sub
Private Sub s_Click()
End Sub