Bonjour,
A l'aide de la macro ci-dessous je converti mon fichier .xls en .txt, le fichier .xls contient 5 colonnes (N°, Etapes, Macro, Fonction et Causes possibles). Dans Fonction et Causes possibles il y a un retour à la ligne auto, mais dans le fichier .txt le retour à la ligne ne se fait que dans Causes possibles.
Est-ce que quelqu'un pourrait me dire pourquoi le retour à la ligne ne se fait pas pour la colonne Fonction dans le fichier .txt. Je n'ai aucune notion de VisualBasic
Ma macro:
Sub Generation()
Dim Chemin As String
Dim NomFichier As String
Dim Num As String
Dim Etape As String
Dim Macro As String
Dim Fonction As String
Dim CausePossible As String
Dim AlarmeFin As String
Dim cpt As Integer
AlarmeFin = "1599"
Range("a4").Select
NomFichier = "C:\Program Files\Schneider Electric\Vijeo-Designer\Vijeo-Frame\Vijeo-Manager\Alarme_G39.txt"
Open NomFichier For Output As #1
Print #1, "::"
Do
If ActiveCell.Text = "" Then
Selection.Offset(1, 0).Range("a1").Select
GoTo fin
End If
Num = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
Etape = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
Macro = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
Fonction = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
CausePossible = ActiveCell.Text
Selection.Offset(1, -4).Range("a1").Select
Dim i As Integer
Dim j As Integer
Dim lgString As Integer
Dim nbLigne As Integer
Dim lgStringInterne As Integer
Dim posString As Integer
Dim Tableau(50) As String
nbLigne = 0
posString = 1
CausePossible = CausePossible + Chr(10)
lgString = Len(CausePossible)
For i = 1 To lgString
If Mid(CausePossible, i, 1) = Chr(10) Then
lgStringInterne = i - posString
Tableau(nbLigne) = Mid(CausePossible, posString, lgStringInterne)
nbLigne = nbLigne + 1
posString = i + 1
End If
Next
Print #1, "::"
Print #1, "ALARME N° " & Num
Print #1, "--------------"
Print #1, "ETAPE: " & Etape & " - " & Macro
Print #1, "FONCTION: " & Fonction
Print #1, ""
Print #1, "CAUSES POSSIBLES:"
If Tableau(0) <> "" Then
For j = 0 To (nbLigne - 1)
Print #1, "- " + Tableau(j)
Next
End If
fin:
cpt = cpt + 1
Loop Until ActiveCell = AlarmeFin Or cpt > 610
Close #1
Range("a4").Select
End Sub
A l'aide de la macro ci-dessous je converti mon fichier .xls en .txt, le fichier .xls contient 5 colonnes (N°, Etapes, Macro, Fonction et Causes possibles). Dans Fonction et Causes possibles il y a un retour à la ligne auto, mais dans le fichier .txt le retour à la ligne ne se fait que dans Causes possibles.
Est-ce que quelqu'un pourrait me dire pourquoi le retour à la ligne ne se fait pas pour la colonne Fonction dans le fichier .txt. Je n'ai aucune notion de VisualBasic
Ma macro:
Sub Generation()
Dim Chemin As String
Dim NomFichier As String
Dim Num As String
Dim Etape As String
Dim Macro As String
Dim Fonction As String
Dim CausePossible As String
Dim AlarmeFin As String
Dim cpt As Integer
AlarmeFin = "1599"
Range("a4").Select
NomFichier = "C:\Program Files\Schneider Electric\Vijeo-Designer\Vijeo-Frame\Vijeo-Manager\Alarme_G39.txt"
Open NomFichier For Output As #1
Print #1, "::"
Do
If ActiveCell.Text = "" Then
Selection.Offset(1, 0).Range("a1").Select
GoTo fin
End If
Num = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
Etape = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
Macro = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
Fonction = ActiveCell.Text
Selection.Offset(0, 1).Range("a1").Select
CausePossible = ActiveCell.Text
Selection.Offset(1, -4).Range("a1").Select
Dim i As Integer
Dim j As Integer
Dim lgString As Integer
Dim nbLigne As Integer
Dim lgStringInterne As Integer
Dim posString As Integer
Dim Tableau(50) As String
nbLigne = 0
posString = 1
CausePossible = CausePossible + Chr(10)
lgString = Len(CausePossible)
For i = 1 To lgString
If Mid(CausePossible, i, 1) = Chr(10) Then
lgStringInterne = i - posString
Tableau(nbLigne) = Mid(CausePossible, posString, lgStringInterne)
nbLigne = nbLigne + 1
posString = i + 1
End If
Next
Print #1, "::"
Print #1, "ALARME N° " & Num
Print #1, "--------------"
Print #1, "ETAPE: " & Etape & " - " & Macro
Print #1, "FONCTION: " & Fonction
Print #1, ""
Print #1, "CAUSES POSSIBLES:"
If Tableau(0) <> "" Then
For j = 0 To (nbLigne - 1)
Print #1, "- " + Tableau(j)
Next
End If
fin:
cpt = cpt + 1
Loop Until ActiveCell = AlarmeFin Or cpt > 610
Close #1
Range("a4").Select
End Sub