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
| #If Win64 Then Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
#Else
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
#End If
Const VK_TAB As Long = &H9
Const KEYEVENTF_KEYUP As Long = &H2
Const VK_RETURN As Long = &HD
Const URL = "https://www.euronext.com/fr/popup/data/download?ml=nyx_pd_stocks&cmd=default&formKey=nyx_pd_filter_values%3A1006ef55d4998cc0fad71db6a6f38530"
Dim OK%
Dim eXtention
Dim wbkname As String
Sub euronext_csv()
DemoEuroNext_all_format 1, ".csv", 1
End Sub
Sub euronext_xls()
DemoEuroNext_all_format 1, ".xls"
End Sub
Function DemoEuroNext_all_format(mode, eXt, Optional separ)
Dim hWnDEuronext As Long
Dim hWnDbandeau As Long
' on choisi l'extention xls
Const EG = "edit-go"
eXtention = eXt
wbkname = Environ("USERPROFILE") & "\Downloads\Euronext_Equities_EU_" & Format(Date, "yyyy-mm-dd") & eXtention
With CreateObject("InternetExplorer.Application")
.Navigate URL
.Visible = True
While .busy Or .ReadyState < 4: DoEvents: Wend
OK = IsObject(.Document.all(EG))
If OK Then
Select Case eXt
Case ".xls": .Document.all("edit-format-1").Checked = True
Case ".csv"
.Document.all("edit-format-2").Checked = True
Select Case separ
'le document.all ne fonctionnant pas avec le id comme reference j'utilise le getelementbyid(difference entre moi et marc )
' probleme recurent entre les versions de IE
Case 1: .Document.getelementbyid("edit-decimal-separator-1").Checked = True
Case 2: .Document.getelementbyid("edit-decimal-separator-2").Checked = True
End Select
End Select
.Document.all(EG).Click
' affiche la fenetre avnt d'appuyer sur les bouton du bandeau de telechargement (facultaif ) fonctionne meme sans
Do
DoEvents
hWnDEuronext = FindWindow("IEFrame", vbNullString)
Loop While hWnDEuronext = 0
Do
DoEvents
hWnDbandeau = FindWindowEx(hWnDEuronext, 0&, "Frame Notification Bar", vbNullString)
Loop While hWnDbandeau = 0
Sleep 500
keybd_event VK_TAB, 0, 0, 0&
keybd_event VK_TAB, 0&, KEYEVENTF_KEYUP, 0&
Sleep 100
keybd_event VK_TAB, 0, 0, 0&
keybd_event VK_TAB, 0&, KEYEVENTF_KEYUP, 0&
Sleep 100
keybd_event VK_RETURN, 0, 0, 0&
keybd_event VK_RETURN, 0&, KEYEVENTF_KEYUP, 0&
Sleep 100
' .Quit
Else
.Quit: Beep
End If
End With
End Function |
Partager