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
| Option Explicit
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal Milliseconds As LongPtr)
Function GetobIEOBject(URL As String) As Object
Dim objShell As Object
Dim obj As Object
Set objShell = CreateObject("shell.application")
For Each obj In objShell.Windows
'If TypeName(obj.document) = "HTMLDocument" Then
If obj.LocationURL = URL Then Set GetobIEOBject = obj
'End If
Next obj
End Function
Sub WaitIE(objIE As InternetExplorer)
'On boucle tant que la page n'est pas totalement chargée
Do While objIE.Busy: DoEvents: Loop
Do Until objIE.readyState = READYSTATE_COMPLETE: DoEvents: Loop
End Sub
Sub Essai()
Dim IE1 As InternetExplorer
Dim IE2 As InternetExplorer
Dim IE1Doc As HTMLDocument
Dim IE2Doc As HTMLDocument
Dim Frame1_Doc As HTMLDocument
Dim htmltable As htmltable
Dim Generic As HTMLGenericElement
Dim B_Aff_Banque_Horraire As HTMLGenericElement
Dim URL As String
Dim URL2 As String
Dim tag As String
Dim CP As String
Dim index As Integer
' Affedction des variable adresse site internet"
URL = "http://www.psgt.infra.sncf.fr/servlets/ServCilvAction"
URL2 = "http://www.psgt.infra.sncf.fr/Tap/Gerer/TapGrHoraire.jsp"
' affectation du site sur URL à la l'objet EI2
Set IE1 = GetobIEOBject(URL)
Set IE1Doc = IE1.document
IE1.Visible = True
'dans le document HTML (de IE1) un nouveau dcument est attaché a une balise frame
'Affectation variable pour document balise frame 1
Set Frame1_Doc = IE1Doc.frames("contenu").document.frames.Item(1).document
' recherche du formulaire HTML
For index = 0 To 200
Set Generic = Frame1_Doc.getElementsByTagName("form")(index)
On Error GoTo saut1
If Generic.Name = "Formulaire" Then
Exit For
End If
Next
' Recherche de la table générale identifié par la class "nn"
For index = 0 To 200
Set htmltable = Generic.getElementsByTagName("table")(index)
On Error GoTo saut1
If htmltable.ClassName = "nn" Then
Exit For
End If
Next
' Recherche de la table contenu - pas de name, id, ou class etc...
Set htmltable = htmltable.Children(0).Children(1).Children(0).Children(1)
' Rechercher Afficher banque horraire pas de name, id, ou class etc...
Set B_Aff_Banque_Horraire = htmltable.Children(1).Children(0).Children(0).Children(0)
' Commande de clic sur le boutton "Afficher banque horaire"
B_Aff_Banque_Horraire.Click
'==> a ce niveau du programme la fenetre popup d'ouvre.
'code pour associer la page popup a l'objet IE2
'==> IE2 is nothiong
URL2 = "http://www.psgt.infra.sncf.fr/Tap/Gerer/TapGrHoraire.jsp"
Sleep (2000)
Set IE2 = GetobIEOBject(URL2)
Sleep (2000)
Set IE2Doc = IE1.document
'//////////////////////////////////////////////////////////////////////
'Routine de remplissage a réaliser
'//////////////////////////////////////////////////////////////////////
'boucle pour trouver la case du tableau de la du mois et entree le code horraire
' il gau = "AJ_" & Jou_du_mois & "_AG_" & CP & "_"
For index = 0 To 200
Set Generic = Frame1_Doc.all.Item(index)
If Generic.ID = "AJ_5_AG_6801083G_" Then
Generic.Click
Exit For
End If
Next
saut1:
MsgBox "fin"
End Sub
Sub Fenetres_IE()
'Nécessite d'activer la référence
'"Microsoft Internet Controls"
'et
'"Microsotf HTML Object Library"
Dim IE As New InternetExplorer
Dim winShell As New ShellWindows
Dim maPageHtml As HTMLDocument
On Error Resume Next
For Each IE In winShell
If IE.LocationURL <> "" Then
Set maPageHtml = IE.document
MsgBox maPageHtml.DocumentElement.innerText
Set maPageHtml = Nothing
End If
Next IE
End Sub |
Partager