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
| 'Click sur le bouton
IE2.document.all("uploadAttachments").Click
'Upload du fichier
Do
DoEvents
Hwnd = FindWindow(vbNullString, "Choisir un fichier à télécharger")
i = i + 1
Loop Until Hwnd <> 0 Or i = 2000
If handle_trouvé(Hwnd, "fenetre") = True Then
SetForegroundWindow Hwnd ' cette api ne fonctionne pas tres bien je prefere showindow avec l'indice 9 (affiche et active la fenetre a sa position initiale)
hwnd_level1 = FindWindowEx(Hwnd, 0, "ComboBoxEx32", "")
End If
If handle_trouvé(hwnd_level1, "combo") = True Then
Application.DisplayAlerts = False
Call SendMessageByString(hwnd_level1, WM_SETTEXT, 0&, "D:\Users\u136110\Desktop\" & "x.pdf")
Sleep 100
hwnd_button = FindWindowEx(Hwnd, 0, "Button", "ou&vrir") '&Enregistrer
End If
If handle_trouvé(hwnd_button, "bouton") = True Then
Sleep 100
SendMessage hwnd_button, BM_CLICK, ByVal CLng(0), ByVal CLng(0)
Application.DisplayAlerts = True
End If
Function handle_trouvé(handle, etapemacro) As Boolean
handle_trouvé = False
If handle = 0 Then
Select Case etapemacro
Case "fenetre"
'faire ceci ou cela' ici on peut se permettre d'engager une procedure auxiliaire pour la fenetre
Debug.Print " l etape pour la/le " & etapemacro & "c'est mal passée : son handle n'est pas trouvé"
Case "combo"
' faire cei: ou cela'ici idem
Debug.Print "l etape pour la/le " & etapemacro & "c'est mal passée: son handle n'est pas trouvé"
Case "bouton"
'faire ci: ou cela' ici idem
Debug.Print "l etape pour la/le " & etapemacro & "c'est mal passé : son handle n'est pas trouvé"
End Select
Else
handle_trouvé = True
Debug.Print "l etape pour la/le " & etapemacro & "c'est bien passée : son handle est: " & handle
End If
End Function |
Partager