FMatrix07
Messages postés
233
Date d'inscription
mercredi 26 février 2003
Statut
Membre
Dernière intervention
21 février 2009
2
1 déc. 2005 à 04:49
Bonjour
on change tout ou presque
d'abord
ajoute un module nommé "WriteFile.bas"
colle ceci dedans
Public Function WriteText(FileWrite, ValEntrer)
NomFicSrc = FileWrite
NomFicDesti = "C:\Tempo2.TMP"
'Ouverture des fichiers
NumFicSrc = FreeFile
Open NomFicSrc For Input As NumFicSrc
NumFicDesti = FreeFile
Open NomFicDesti For Output As NumFicDesti
Bcle1 = 0
'Lecture/écriture des fichiers
Do While Not EOF(NumFicSrc)
Line Input #NumFicSrc, msg
If msg <> "" Then Print #NumFicDesti, msg
next1:
Bcle1 = Bcle1 + 1
Loop
'Fermeture des fichiers et ajout de la Valeur d'entrée
Print #NumFicDesti, ValEntrer
Close #NumFicDesti
Close #NumFicSrc
'Changement de nom du fichier Destination
Kill NomFicSrc
Name NomFicDesti As NomFicSrc
End Function
Puis change le command1_Click() par
ceci
Private Sub Command1_Click()
'Declaration du fichier excel
Set Myxlapp = Excel.Application
Myxlapp.Visible = True
Myxlapp.DisplayAlerts = True
'Ouverture du fichier resultatAnalyse
Workbooks.Open FileName:=Text2 & Text4, Origin:=xlWindows
'Recherche derniere ligne pour nouvelle entrée
Columns("A:A").Select
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
i = ActiveCell.Row
Val1 = 1
'Copy du fichier des entrées d'analyse
FileCopy Text1 & Text3, Text1 & Text3 & 1
'Ajout d'un carractere pour trouver la fin du fichier
WriteText Text1 & Text3 & 1, vbCrLf & "F"
'ouverture du fichier des entrées d'analyse
Workbooks.OpenText FileName:=Text1 & Text3 & 1, Origin:=932, StartRow:=1 _
, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(1, 2), Array(3, 2) _
, Array(12, 2), Array(26, 2), Array(42, 2), Array(61, 2)), TrailingMinusNumbers:=True
'Recherche derniere ligne
Columns("A:A").Select
Range("A" & Val1).Activate
Selection.Find(What:="F", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ValFin = ActiveCell.Row
'Recherche des differents patient
Range("B" & Val1).Activate
Do
'Test si c'est une entrée patient different de "I"
If Range("B" & Val1) <> "" And Range("A" & Val1) <> "I" Then
ValPatient = Range("D" & Val1)
ValMatrice = Range("E" & Val1)
ValDate = Range("F" & Val1)
ValHeure = Range("G" & Val1)
Windows(Text4.Text).Activate
Range("A" & i) = ValPatient
Range("B" & i) = ValMatrice
Range("C" & i) = ValDate
Range("D" & i) = ValHeure
Windows(Text3.Text & 1).Activate
Val1 = Val1 + 2
'Recherche de la type et valeur analyse
Do
If Range("B" & Val1) = "" Then
ValAnalyse = Range("C" & Val1)
ValResult = Range("D" & Val1)
End If
Windows(Text4.Text).Activate
'Recherche position colonne analyse si erreur test abs alors ajout de la colonne
Rows("1:1").Select
On Error GoTo AddColumn
Err.Clear
Selection.Find(What:=ValAnalyse, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
GoTo JumpAddColumn
AddColumn:
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ValC1 = ActiveCell.Column
Cells(1, ValC1) = ValAnalyse
Err.Clear
JumpAddColumn:
'Ajout des valeur d'analyse pour le patient
ValC1 = ActiveCell.Column
Cells(i, ValC1) = ValResult
Windows(Text3.Text & 1).Activate
Val1 = Val1 + 1 Loop Until Range("B" & Val1) "" And Range("C" & Val1) ""
i = i + 1
Else
Val1 = Val1 + 1
End If
Loop Until Val1 >= ValFin
Windows(Text3.Text & 1).Activate
ActiveWindow.Close
'Mise en forme du classeur resultat analyse
Columns("A:D").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:A").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1").Select
'Sauvegarde du fichier puis fermeture
ActiveWorkbook.Save
ActiveWorkbook.Close
'Effacer la copie fichier entrée analyse
Kill Text1 & Text3 & 1
'Liberer excel
On Error GoTo Jumping1
Myxlapp.Visible = True
Myxlapp.DisplayAlerts = True
Myxlapp.Quit
Set Myxlapp = Nothing
Jumping1:
End
End Sub
*****************************************
Il y a un seul Bug je n'ai pas trouvé comment resoudre
quand il manque plus d'un type d'analyse dans la classeur ResultAnalyse ça plante
le premier et bien ajouté mais si il y en a un deuxieme malgre le err.clear ça plante
A toi de jouer