Éliminer les erreurs
hakoko
Messages postés
228
Statut
Membre
-
f894009 Messages postés 17414 Date d'inscription Statut Membre Dernière intervention -
f894009 Messages postés 17414 Date d'inscription Statut Membre Dernière intervention -
Bonjour tout le monde,
j'ai une macro qui récupère certaines données provenant d'un fichier texte, le problèmes c'est que quand ce fichier texte n'existe pas mon programme bug. j'ai essayer avec la commande :
On Error Resume Next
ça marche pas . quelqu'un aurai une petite idée svp. merci d'avance.
Sub DerLigne()
Dim Tbl() As String
Dim Ligne As String
Dim I As Integer
Dim txt As String
'adapter le chemin et nom du fichier
txt = ""
'If Fichier = "" Then
' il faut calculer en fonction de la date
Fichier = "a" & Format(Date, "yyyymmdd") & ".TXT"
chemin = "\\*********\data\"
'If Fichier <> "" Then
'End If
On Error Resume Next
'Open "\\***********\data\a20130612.txt" For Input As #1
Open chemin & Fichier For Input As #1
Do While Not EOF(1)
Line Input #1, Ligne
txt = txt & Ligne & vbCrLf
Loop
Close #1
'résultat dans la fenêtre d'exécution (Ctrl+G)
' Debug.Print Tbl(I)
Tbl = Split(txt, vbCrLf)
For I = UBound(Tbl) To 0 Step -1
If Trim("" & Tbl(I)) <> "" Then
Tbl = Split(Tbl(I), Chr(9))
Range(Cells(4, 1), Cells(4, UBound(Tbl))) = Tbl()
Exit For
End If
Next
end Sub
j'ai une macro qui récupère certaines données provenant d'un fichier texte, le problèmes c'est que quand ce fichier texte n'existe pas mon programme bug. j'ai essayer avec la commande :
On Error Resume Next
ça marche pas . quelqu'un aurai une petite idée svp. merci d'avance.
Sub DerLigne()
Dim Tbl() As String
Dim Ligne As String
Dim I As Integer
Dim txt As String
'adapter le chemin et nom du fichier
txt = ""
'If Fichier = "" Then
' il faut calculer en fonction de la date
Fichier = "a" & Format(Date, "yyyymmdd") & ".TXT"
chemin = "\\*********\data\"
'If Fichier <> "" Then
'End If
On Error Resume Next
'Open "\\***********\data\a20130612.txt" For Input As #1
Open chemin & Fichier For Input As #1
Do While Not EOF(1)
Line Input #1, Ligne
txt = txt & Ligne & vbCrLf
Loop
Close #1
'résultat dans la fenêtre d'exécution (Ctrl+G)
' Debug.Print Tbl(I)
Tbl = Split(txt, vbCrLf)
For I = UBound(Tbl) To 0 Step -1
If Trim("" & Tbl(I)) <> "" Then
Tbl = Split(Tbl(I), Chr(9))
Range(Cells(4, 1), Cells(4, UBound(Tbl))) = Tbl()
Exit For
End If
Next
end Sub
A voir également:
- Éliminer les erreurs
- Comment éliminer les publicités - Guide
- Comment eliminer les cookies ordinateur - Guide
- Comment eliminer les pub sur youtube - Accueil - Streaming
- Comment eliminer une page dans word - Guide
- Net user des erreurs ont affecté l'exécution de la commande - Forum Windows