![]() |
XP problem
Have just moved up from 98 to xp and have found that the following code will
not work, any ideas why ??? at the ".FileName" line i am getting a runtime error 5 "Invalid procedure call or argument" It only throws this fault if it finds a file, i.e. if I used "*.hhh" the problem does not arisre because it will not find any such files With Application.FileSearch .LookIn = "C:\Myfile\Preview" .SearchSubFolders = False .FileName = "*.jpg" .Execute For i = 1 To .FoundFiles.Count Next i End With |
XP problem
How about if you use:
..filename = ".jpg" But application.filesearch seems to cause trouble in some versions of windows (some of the time). You may want to go back to using dir(). Option Explicit Sub testme01() Dim myNames() As String Dim fCtr As Long Dim myFile As String Dim myPath As String 'change to point at the folder to check myPath = "c:\my documents\my pictures" If Right(myPath, 1) < "\" Then myPath = myPath & "\" End If myFile = "" On Error Resume Next myFile = Dir(myPath & "*.jpg") On Error GoTo 0 If myFile = "" Then MsgBox "no files found" Exit Sub End If 'get the list of files fCtr = 0 Do While myFile < "" fCtr = fCtr + 1 ReDim Preserve myNames(1 To fCtr) myNames(fCtr) = myFile myFile = Dir() Loop If fCtr 0 Then For fCtr = LBound(myNames) To UBound(myNames) 'code to process the files. 'say MsgBox myPath & myNames(fCtr) Next fCtr End If End Sub Stuart wrote: Have just moved up from 98 to xp and have found that the following code will not work, any ideas why ??? at the ".FileName" line i am getting a runtime error 5 "Invalid procedure call or argument" It only throws this fault if it finds a file, i.e. if I used "*.hhh" the problem does not arisre because it will not find any such files With Application.FileSearch .LookIn = "C:\Myfile\Preview" .SearchSubFolders = False .FileName = "*.jpg" .Execute For i = 1 To .FoundFiles.Count Next i End With -- Dave Peterson |
XP problem
Hi Stuart,
With the problematic workbook open, in the VBE: Tools | References and check that you have a reference set to the MS office object library. --- Regards, Norman "Stuart" wrote in message ... Have just moved up from 98 to xp and have found that the following code will not work, any ideas why ??? at the ".FileName" line i am getting a runtime error 5 "Invalid procedure call or argument" It only throws this fault if it finds a file, i.e. if I used "*.hhh" the problem does not arisre because it will not find any such files With Application.FileSearch .LookIn = "C:\Myfile\Preview" .SearchSubFolders = False .FileName = "*.jpg" .Execute For i = 1 To .FoundFiles.Count Next i End With |
All times are GMT +1. The time now is 12:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com