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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
| Option Explicit
Declare Function GetKeyState Lib "user32" ( _
ByVal nVirtKey As Long) As Integer
Dim stp As Boolean
Sub activation()
'On Error GoTo gestionerreur
Dim i As Integer, MemJ8 As Integer, Memj34 As String
If MsgBox("Assurez-vous que votre session IGOR n'est pas expirée et positionnez-vous sur le menu OUVERTURE SIMPLIFIEE CLIENT-NOUVEAU", vbYesNo, "Demande de confirmation") = vbYes Then
stp = False
AppActivate "essai"
Sheets("RECUP").Select
'POSITIONNEZ-VOUS SUR LE MENU SIMPLIFIE IGOR SOUHAITE
For i = 4 To 13
'***************************************
DoEvents
If stp = True Then Exit Sub
attendre 0.5
SendKeys Range("j4").Value & Chr(13), True
If stp = True Then Exit Sub
attendre 0.6
SendKeys "{ENTER}"
attendre 0.5
Next
For i = 5 To 5
DoEvents
If stp = True Then Exit Sub
attendre 0.5
SendKeys Range("j5").Value & Chr(13), True
attendre 0.5
Next
For i = 6 To 6
DoEvents
If stp = True Then Exit Sub
attendre 0.5
SendKeys Range("j6").Value & Chr(13), True
attendre 0.5
Next
For i = 7 To 7
DoEvents
If stp = True Then Exit Sub
SendKeys Range("j7").Value & Chr(13), True
attendre 0.5
Next
For i = 8 To 25
DoEvents
If stp = True Then Exit Sub
' Si I = 8 alor on mémorise la valeur de la cellule
If i = 8 Then MemJ8 = Range("J8").Value
' Si I = 17 ou 18
If i = 17 Or i = 18 Then
If MemJ8 = 3 Then
attendre 0.5
SendKeys Cells(i, 10).Value, True
If stp = True Then Exit Sub
SendKeys "~"
If stp = True Then Exit Sub
attendre 0.5
End If
Else
' Si I à une autre valeur que 17 ou 18
SendKeys Cells(i, 10).Value, True
If stp = True Then Exit Sub
attendre 0.7
SendKeys "~"
attendre 0.6
End If
Next
For i = 26 To 45
DoEvents
If stp = True Then Exit Sub
' si la valeur dans J34 est autre que BF, on fait ENTER
If i = 34 Then Memj34 = Range("J34").Value
SendKeys Cells(i, 10).Value, True
attendre 0.5
' si i = 34
If i = 34 Then
If Memj34 <> "BF" Then
SendKeys "{ENTER}"
If stp = True Then Exit Sub
SendKeys "~"
If stp = True Then Exit Sub
attendre 0.7
End If
Else
SendKeys Cells(i, 10).Value, True
attendre 0.5
If stp = True Then Exit Sub
SendKeys "~"
If stp = True Then Exit Sub
attendre 0.7
End If
Next
SendKeys "+{F3}"
If stp = True Then Exit Sub
attendre 0.7
For i = 46 To 53
DoEvents
If stp = True Then Exit Sub
SendKeys Cells(i, 10).Value, True
If stp = True Then Exit Sub
attendre 0.5
SendKeys "~"
If stp = True Then Exit Sub
attendre 0.7
Next
SendKeys "+{F6}"
If stp = True Then Exit Sub
attendre 0.7
For i = 54 To 54
DoEvents
If stp = True Then Exit Sub
SendKeys Cells(i, 10).Value, True
If stp = True Then Exit Sub
attendre 0.7
SendKeys "~"
attendre 0.7
Sheets("DONNE").Select
Range("E4").Select
Next
Exit Sub
gestionerreur:
MsgBox "fichier non ouvert ou réduit dans la barre des tâches : abandon"
End If
End Sub
Sub attendre(sec%)
Dim deb&, fin&
deb = Timer
fin = deb + sec%
Do Until Timer >= fin
DoEvents
If GetKeyState(27) > 0 Then
'If MsgBox("Confirmation arrêt macro", vbOKCancel + vbQuestion) = vbOK Then
'SendKeys Chr(27)
stp = True
Exit Sub
'End If
SendKeys Chr(27)
End If
Loop
End Sub |
Partager