1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| Private Sub Workbook_Open()
Dim N As Variant, ligne As String ', xlFixedWidth As Variant
Dim a As Variant, K As Integer, Km As Variant
Dim Ar(4) As Variant
Dim i As Integer
'On Error Resume Next
'ouverture du fichier texte en lecture affecté a #1
Open ActiveWorkbook.Path & "\res1.txt" For Input As #1 ', DataType:=xlFixedWidth , Tab:=True
'lecture premiere ligne
Line Input #1, ligne
'MsgBox ligne
'increment de ligne
K = 1
'ouverture de la feuille résultat
Worksheets("Résultats").Select
'boucle tant que le fichier a des données
While EOF(1) = False
'changement de ligne
K = K + 1
'lecture des lignes
Line Input #1, Km
Ar(1) = Mid(Km, 1, 10)
'Left(Km, NombreDeCaractères)
Ar(2) = Mid(Km, 11, 9)
Ar(3) = Mid(Km, 20, 11)
Ar(4) = Mid(Km, 31, 11)
'affichage des lignes
For i = 1 To 4
Ar(i) = Trim(Ar(i))
Cells(K, i).Value = Ar(i)
Next
'calcul vitesse de fissuration
If (K > 2) Then
Cells(K, 7).FormulaR1C1 = "=(RC[-5]-R[-1]C[-5])/(RC[-6]-R[-1]C[-6])"
End If
Wend
Close #1
MsgBox "Hello1"
'graph a(N)
'choix d'une courbe avec lissage
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Courbe avec lissage"
MsgBox "Hello"
ActiveChart.SetSourceData Source:=Sheets("Résultats").Range("B2:B6"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection(1).XValues = "=Résultats!R2C1:R6C1"
ActiveChart.SeriesCollection(1).Name = _
"=""fissure en fonction du nombre de cycle"""
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasDataTable = False
End Sub |
Partager