Hi!, i can not insert 3 strings values in 3 table fields! I think the fault is the string "strDOCfile = f.Name" because his value is a file name like "file.DOC" and i have operator error on debugger.
Code:
Sub EBA()
Dim fs, f, s
Dim SourceDir As String 'The source directory
Dim ArqExiste As Boolean
Dim file As String
Dim CODCVM As String
Dim BUSCACODCVM As Variant
Dim DATAITR As String
Dim BUSCADATAITR As Variant
SourceDir = "C:\" 'Diretorio onde estao os .DOC
Set fs = CreateObject("Scripting.FileSystemObject")
Set folder = fs.GetFolder(SourceDir)
For Each f In folder.files
If Mid(f.Name, Len(f.Name) - 3) = ".DOC" Then
strEmp = "5410"
strDate = "1012008"
file = SourceDir & f.Name
strDOCfile = f.Name
ArqExiste = FileExists(file)
If ArqExiste = True Then
Dim sSQL As String
Dim dbs As Database
Set dbs = CurrentDb()
[b]
sSQL = "Insert Into DOC(CODemp,DOCdate,File) Values ('" & strEmp & "' , " & strDate & ", " & strDOCfile & ") "
[/b]
dbs.Execute sSQL
End If
End If
Next
End Sub