I'm attempting to obtain names of files and place them as text into a database using the code below (posted in this forum previously). A problem arises at the last line of code when the following error appears highlighting 'RowSource' :
Compile error: Method or data member not found
Is it something to do with the references that have been selected?
Private Sub Command7_Click()
Dim i As Integer
Dim strRow As String
Dim strSearch As String
'set the search string
strSearch = "c:\My Documents"
With Application.FileSearch
.LookIn = strSearch
.SearchSubFolders = False
.MatchTextExactly = True
.FileType = msoFileTypeExcelWorkbooks
.Execute
MsgBox .FoundFiles.Count & " files found"
For i = 1 To .FoundFiles.Count
strRow = strRow & Mid(.FoundFiles(i), Len(strSearch) + 2, 500) & ";"
Next i
End With
Me.lbxfilelist.RowSource = Left(strRow, Len(strRow) - 1)
End Sub
Compile error: Method or data member not found
Is it something to do with the references that have been selected?
Private Sub Command7_Click()
Dim i As Integer
Dim strRow As String
Dim strSearch As String
'set the search string
strSearch = "c:\My Documents"
With Application.FileSearch
.LookIn = strSearch
.SearchSubFolders = False
.MatchTextExactly = True
.FileType = msoFileTypeExcelWorkbooks
.Execute
MsgBox .FoundFiles.Count & " files found"
For i = 1 To .FoundFiles.Count
strRow = strRow & Mid(.FoundFiles(i), Len(strSearch) + 2, 500) & ";"
Next i
End With
Me.lbxfilelist.RowSource = Left(strRow, Len(strRow) - 1)
End Sub