Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) | |||
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? | Excel Programming |