Application.FileSearch.FoundFiles Error 9 Subscript out of Range

  • Thread starter Thread starter jhansen
  • Start date Start date
J

jhansen

I am using Accusoft ImageGear to display images in my application. In
order to pass the image to my function, I am calling
Application.FileSearch.FoundFiles and randomly getting Run-Time Error
9: Subscript out of Range. I realize that the FoundFiles is an object
that contains the names of all the files found during a search, but I
am only working with 9 files.


Private Sub btnPrevPage_Click()
Dim nIdx As Integer
Dim sFoundFiles As String

nIdx = igImage.PrevPageMultJPG(Me!txtPageNum, Me!txtPageCount)
sFoundFiles = Application.FileSearch.FoundFiles(nIdx)
igImage.LoadImageMultJPG sFoundFiles, , Me!txtPageNum,
Me!txtPageCount

End Sub
 
The errors happen randomly, however, on this time I was able to get it
to break when nIdx = 6. There are a total of 12 files that should be
in the FoundFiles object. When I tried to verify that there were 12
foundfiles, I typed Application.FileSearch.FoundFiles.Count in the
immediate window and got 0. Therefore, somehow the FoundFiles object
must be dropping the number of files found in a recent search. That
would explain the Subscript out of Range error I am receiving. I need
to revisit my code to decipher why the FoundFiles is losing its data.
 
Back
Top