- '1 coltrole ole -> OLE2
- '2 textbox -> txtorg et txt_ligne_cmd
- '1 bouton ->cmd_valide_ligne
-
- Private Sub cmd_valide_ligne_Click()
- Dim Excel As Excel.Application
- Dim str3, str4 As String
- Dim col1, col2 As String
- Dim cpt, cpt2 As String
- mvt1 = False
- cpt = "1"
- cpt2 = "2"
- Set Excel = CreateObject("excel.application")
-
- Excel.Workbooks.Add
-
- Me.txtorg = Me.txtorg + Me.txt_ligne_cmd + Chr(13) 'met un caractere de fin d'activite
- str3 = Me.txtorg
- Do
- 'increment de la colone ax
- col1 = "A" & cpt
- col2 = "A" & cpt2
-
-
- str4 = Mid(str3, 1, InStr(1, str3, Chr(13)))
- str4 = Left(str4, Len(str4) - 1)
-
- Excel.Range(col1).Value = str4
- Excel.Range(col2).Rows.RowHeight = 8
- Excel.Range(col2).Value = "|"
- Excel.Range(col1).Borders.Weight = xlMedium
- Excel.Range(col1).Interior.ColorIndex = 44
- str3 = Mid(str3, Len(str4) + 2)
-
- cpt = Str((CInt(cpt) + 2))
- cpt = Right(cpt, Len(cpt) - 1)
- cpt2 = Str((CInt(cpt2) + 2))
- cpt2 = Right(cpt2, Len(cpt2) - 1)
- Loop Until Len(str3) = 0
-
- 'formatage de la colone A
- With Excel.Range("a1:a10")
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlVAlignCenter
- .WrapText = True
- .Orientation = 0
- .AddIndent = False
- .ShrinkToFit = False
- .MergeCells = False
- End With
- 'copy du fichier dans excel
- Excel.Worksheets(1).Range("a1:a" + cpt2).Copy
- OLE2.OLETypeAllowed = 1
- OLE2.Action = 5
-
- 'ferme l'applique excel
- Excel.DisplayAlerts = False ' mettre a true pour mettre la msgbox de sauvegarde d'excel
- Excel.Application.Quit 'quitte excel
- Set Excel = Nothing
-
- End Sub
-
- Private Sub Form_Load()
-
- End Sub
'1 coltrole ole -> OLE2
'2 textbox -> txtorg et txt_ligne_cmd
'1 bouton ->cmd_valide_ligne
Private Sub cmd_valide_ligne_Click()
Dim Excel As Excel.Application
Dim str3, str4 As String
Dim col1, col2 As String
Dim cpt, cpt2 As String
mvt1 = False
cpt = "1"
cpt2 = "2"
Set Excel = CreateObject("excel.application")
Excel.Workbooks.Add
Me.txtorg = Me.txtorg + Me.txt_ligne_cmd + Chr(13) 'met un caractere de fin d'activite
str3 = Me.txtorg
Do
'increment de la colone ax
col1 = "A" & cpt
col2 = "A" & cpt2
str4 = Mid(str3, 1, InStr(1, str3, Chr(13)))
str4 = Left(str4, Len(str4) - 1)
Excel.Range(col1).Value = str4
Excel.Range(col2).Rows.RowHeight = 8
Excel.Range(col2).Value = "|"
Excel.Range(col1).Borders.Weight = xlMedium
Excel.Range(col1).Interior.ColorIndex = 44
str3 = Mid(str3, Len(str4) + 2)
cpt = Str((CInt(cpt) + 2))
cpt = Right(cpt, Len(cpt) - 1)
cpt2 = Str((CInt(cpt2) + 2))
cpt2 = Right(cpt2, Len(cpt2) - 1)
Loop Until Len(str3) = 0
'formatage de la colone A
With Excel.Range("a1:a10")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlVAlignCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
'copy du fichier dans excel
Excel.Worksheets(1).Range("a1:a" + cpt2).Copy
OLE2.OLETypeAllowed = 1
OLE2.Action = 5
'ferme l'applique excel
Excel.DisplayAlerts = False ' mettre a true pour mettre la msgbox de sauvegarde d'excel
Excel.Application.Quit 'quitte excel
Set Excel = Nothing
End Sub
Private Sub Form_Load()
End Sub