Bonjour à tous,
Ca faisait un moment que je n'étais pas revenu sur le forum, je me tourne vers vous aujourd'hui pour une aide sur la compréhension du code ci dessous. ce code est issu du fichier joint que @Thierry à bien voulu réaliser pour mes besoins (le fil initial date du 03/09/05 à 11h49 désolé je ne sais pas faire les liens)
jusqu'au '?????????? je comprends mais après c'est beaucoup plus flou, j'aurai besoin d'adapter ce type de fichier à d'autres applications et pour cela il me faut comprendre ce que je fais.
Merci donc à tous ceux qui pourront m'aider.
Sub ImportTXT()
Dim Record As String
Dim Container As Variant
Dim i As Integer, ii As Byte, iii As Byte
Dim ThePath As String
Dim MaxCol As Byte
ThePath = Range("TxbBrowseForFolder") & "\"
If TestFichier(ThePath & Range("TXT2") & ".txt") = True Then
Open ThePath & Range("TXT2") & ".txt" For Input As #1
GoTo TheFinalStep
End If
If TestFichier(ThePath & Range("TXT3") & ".txt") = True Then
Open ThePath & Range("TXT3") & ".txt" For Input As #1
GoTo TheFinalStep
Else
GoTo FatalError
End If
'?????????????
TheFinalStep:
i = 1
Do While Not EOF(1)
Line Input #1, Record
Container = Split(Record, Chr(9))
On Error GoTo FatalError
MaxCol = IIf(Range("TXBColumns") + 1 > UBound(Container) + 1, UBound(Container) + 1, Range("TXBColumns") + 1)
For ii = 1 To MaxCol
iii = ii - 1
Import.Cells(i, ii) = Container(iii)
Next ii
i = i + 1
If i = Range("TXBLines") + 3 Then Exit Do
Loop
Close #1
'pour test du timer
Import.Range("A1") = Format(Now, "HH:MM:SS")
Exit Sub
FatalError:
StopUpdateTXT
MsgBox "Les Fichier Txt n'existent pas dans " & ThePath
End Sub
@ plus
Jacques
Ca faisait un moment que je n'étais pas revenu sur le forum, je me tourne vers vous aujourd'hui pour une aide sur la compréhension du code ci dessous. ce code est issu du fichier joint que @Thierry à bien voulu réaliser pour mes besoins (le fil initial date du 03/09/05 à 11h49 désolé je ne sais pas faire les liens)
jusqu'au '?????????? je comprends mais après c'est beaucoup plus flou, j'aurai besoin d'adapter ce type de fichier à d'autres applications et pour cela il me faut comprendre ce que je fais.
Merci donc à tous ceux qui pourront m'aider.
Sub ImportTXT()
Dim Record As String
Dim Container As Variant
Dim i As Integer, ii As Byte, iii As Byte
Dim ThePath As String
Dim MaxCol As Byte
ThePath = Range("TxbBrowseForFolder") & "\"
If TestFichier(ThePath & Range("TXT2") & ".txt") = True Then
Open ThePath & Range("TXT2") & ".txt" For Input As #1
GoTo TheFinalStep
End If
If TestFichier(ThePath & Range("TXT3") & ".txt") = True Then
Open ThePath & Range("TXT3") & ".txt" For Input As #1
GoTo TheFinalStep
Else
GoTo FatalError
End If
'?????????????
TheFinalStep:
i = 1
Do While Not EOF(1)
Line Input #1, Record
Container = Split(Record, Chr(9))
On Error GoTo FatalError
MaxCol = IIf(Range("TXBColumns") + 1 > UBound(Container) + 1, UBound(Container) + 1, Range("TXBColumns") + 1)
For ii = 1 To MaxCol
iii = ii - 1
Import.Cells(i, ii) = Container(iii)
Next ii
i = i + 1
If i = Range("TXBLines") + 3 Then Exit Do
Loop
Close #1
'pour test du timer
Import.Range("A1") = Format(Now, "HH:MM:SS")
Exit Sub
FatalError:
StopUpdateTXT
MsgBox "Les Fichier Txt n'existent pas dans " & ThePath
End Sub
@ plus
Jacques