1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
' importation auto de tous les fichiers text du répertoire guardians selon datej
Public Sub ImportDj()
Dim FileName, FilePathName, Path, FileNamelist() As String
Dim FileCount As Integer
Dim Message, Title, Default, MyValue
Message = "Début du nom de fichier"
Title = "Variable extraction"
Default = "G10220118"
MyValue = InputBox(Message, Title, Default)
DoCmd.SetWarnings False
Path = "W:\FTP\RSFLERS\rapport_guardian2\"
FileName = Dir(Path & "")
While FileName <> "" And Right(FileName, 3) = "txt" And Left(FileName, 9) = "MyValue"
FileCount = FileCount + 1
ReDim Preserve FileNamelist(1 To FileCount)
FileNamelist(FileCount) = FileName
FileName = Dir()
Wend
If FileCount > 0 Then
For FileCount = 1 To UBound(FileNamelist)
FilePathName = Path & FileNamelist(FileCount)
DoCmd.TransferText transferType:=acImportDelim, SpecificationName:="SpeImport", TableName:=FileNamelist(FileCount), FileName:=FilePathName, hasfieldnames:=False
Next
End If
DoCmd.SetWarnings True
MsgBox ("terminé !")
End Sub |
Partager