Compréhension d'un code VBA

Jacques25

XLDnaute Occasionnel
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
 

Pièces jointes

  • USF_TXT_Timed_Import_V02.zip
    21.6 KB · Affichages: 19
  • USF_TXT_Timed_Import_V02.zip
    21.6 KB · Affichages: 17
  • USF_TXT_Timed_Import_V02.zip
    21.6 KB · Affichages: 19

Discussions similaires

Réponses
6
Affichages
275
Réponses
0
Affichages
175

Statistiques des forums

Discussions
312 413
Messages
2 088 199
Membres
103 764
dernier inscrit
nissassa