Salut Lermite
Je n'arrive pas à exécuter la macro.
Quand je l'exécute, ca signale variable non définie.
A quoi correspond le user32?
Aussi quelle touche dois-je taper pour l'arrêt de la macro?
Ci-dessous le code et le fichier joint pour tester vous :
pour le teste, vous créer un document word nommé essai.
Option Explicit
Declare Function GetKeyState Lib "user32" ( _
ByVal nVirtKey As Long) As Integer
Dim NoAction As Boolean
Sub activation()
'On Error GoTo gestionerreur
If MsgBox("ASSUREZ-VOUS QUE VOTRE", vbYesNo, "Demande de confirmation") = vbYes Then
NoAction = False
AppActivate "essai"
For I = 3 To 43
SendKeys Cells(I, 4).Value, True
attendre 0.6
If NoAction Then Exit Sub
SendKeys "~"
attendre 1
If NoAction Then Exit Sub
Next
SendKeys "+{F3}"
attendre 1
If NoAction Then Exit Sub
For I = 44 To 51
SendKeys Cells(I, 4).Value, True
attendre 0.6
If NoAction Then Exit Sub
SendKeys "~"
attendre 1
If NoAction Then Exit Sub
Next
SendKeys "+{F6}"
attendre 1
If NoAction Then Exit Sub
For I = 52 To 52
SendKeys Cells(I, 4).Value, True
attendre 0.6
If NoAction Then Exit Sub
SendKeys "~"
attendre 1
If NoAction Then Exit Sub
Next
End If
Exit Sub
gestionerreur:
MsgBox "fichier non ouvert ou réduit dans la barre des tâches : abandon"
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)
NoAction = True
Exit Sub
End If
SendKeys Chr(27)
End If
Loop
End Sub