Have a issue related to thread701-1551678
I am attempting to achieve a similar result, this time with excel files.
code:
Everything should work.... only changes I have made is regarding the extensions it is looking for and the path variables.
I still use process of using a batch rename to rename all files with a autonumber 00000000.xls, 00000001.xls etc on all xls files in a specific folder and its subfolders.
The script above finds and attempts to do the necessary, however, when run I get the following error message:
Run-time error '3051'.
The Microsoft Jet Database engine cannot open the file 'C\Documents and Settings\Mark Harris\Desktop\Flowline'. It is already opened exclusively by another user, or you need permission to view its data.
Any ideas what this might be and how to resolve?
I am attempting to achieve a similar result, this time with excel files.
code:
Code:
Private Sub cmdImport_Click()
DoCmd.SetWarnings False
Dim i As Integer
Dim SQL As String
DoCmd.RunSQL "DELETE tbl_FlowlineImportGPS.* FROM tbl_FlowlineImportGPS;"
With FileSearch
.NewSearch
.SearchSubFolders = True
.MatchTextExactly = True
.LookIn = "C:\Documents and Settings\mark harris\Desktop\Flowline\" & [cbo_InsptypeFolder]
.filename = "00*.xls"
.Execute
If .Execute() > 0 Then
MsgBox "There were " & .Foundfiles.Count & _
" file(s) found"
For i = 1 To .Foundfiles.Count
List2.AddItem (.Foundfiles(i))
MsgBox .Foundfiles(i)
filename = Mid(.Foundfiles(i), InStr(.Foundfiles(i), ".xls") - 8)
SQL = "Insert into [tbl_FlowlineImportGPS]" _
& " Select """ & (.Foundfiles(i)) & """ as [Key],*" _
& " from " & "[" & Left(filename, InStr(filename, ".xls") - 1) & "]" _
& " IN """ & Left(.Foundfiles(i), InStr(.Foundfiles(i), ".xls") - 10) & """ ""Excel 8.0;"""
DoCmd.RunSQL SQL
Next i
Else
MsgBox "There were no files found"
End If
End With
DoCmd.SetWarnings True
ErrHandler:
MsgBox Err.Description
End Sub
Everything should work.... only changes I have made is regarding the extensions it is looking for and the path variables.
I still use process of using a batch rename to rename all files with a autonumber 00000000.xls, 00000001.xls etc on all xls files in a specific folder and its subfolders.
The script above finds and attempts to do the necessary, however, when run I get the following error message:
Run-time error '3051'.
The Microsoft Jet Database engine cannot open the file 'C\Documents and Settings\Mark Harris\Desktop\Flowline'. It is already opened exclusively by another user, or you need permission to view its data.
Any ideas what this might be and how to resolve?