Bonjour,

Je souhaite pouvoir récupérer le contenu d'un tableau sur une page web et le transférer sur un fichier excel.

J'ai testé un premier programme mais il ne récupère pas le tableau souhaité. Je voudrais extraire le tableau ("dataview")

Le chemin du tableau est :
<HTML
<Table id="Page container"
<tbody
<tr
<td id="contentcontainer"
<div id ="content"
<table id="dataview

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Sub CopyTables()
    'Déclaration des variables
Dim IE As New InternetExplorer
Dim IEDoc As HTMLDocument
Dim InputGoogleZoneTexte As HTMLInputElement
Dim InputGoogleBouton As HTMLInputElement
Dim FormGoogleCherche As HTMLFormElement
Dim htmlSelectElem As HTMLSelectElement
Dim dataview As HTMLTable
Dim txt As String
Dim i As Long
i = 0
 
 
 
   'Chargement d'une page web
   IE.navigate "http://10.176.36.20/waf/"
 
   'Affichage de la fenêtre IE
   IE.Visible = True
 
   'On attend le chargement complet de la page
   WaitIE IE
   Application.Wait (Now + TimeValue("00:00:01"))
 
   'On pointe le membre Document
   Set IEDoc = IE.document
 
      'On pointe notre Zone de texte
    Set InputGoogleZoneTexte = IEDoc.all("j_username")
 
    'On définit le texte que l'on souhaite placer à l'intérieur
    InputGoogleZoneTexte.Value = "supervisor"
 
    'On pointe notre Zone de texte
    Set InputGoogleZoneTexte = IEDoc.all("j_password")
 
    'On définit le texte que l'on souhaite placer à l'intérieur
    InputGoogleZoneTexte.Value = "supervisor"
 
    'On pointe la Form qui contient Zone de Texte + Bouton (entre autres)
    Set FormGoogleCherche = IEDoc.forms("loginform")
 
    'On exécute l'action Submit de la Form
    FormGoogleCherche.submit
 
   'On attend le chargement complet de la page
   WaitIE IE
   Application.Wait (Now + TimeValue("00:00:01"))
 
   'Chargement d'une page web
   IE.navigate "http://10.176.36.20/waf/MenuTree.do?groupId=Reports&pageId=0&pageId=0&ticket=0"
 
   'On attend le chargement complet de la page
   WaitIE IE
 
   'Chargement d'une page web
   IE.navigate "http://10.176.36.20/waf/protected/system/reports/missingReport.jsp?pageId=0&ticket=1"
 
   'On attend le chargement complet de la page
   WaitIE IE
 
   Set IEDoc = IE.document
 
   'On va sur l'objet qui contient la liste des indices
   Set htmlSelectElem = IEDoc.all("waveID")
 
   'On sélectionne l'indice "ter" via l'index
   htmlSelectElem.selectedIndex = 1
 
   'On pointe la Form qui contient Zone de Texte + Bouton (entre autres)
    Set FormGoogleCherche = IEDoc.forms("missingReportSelectionFilterForm")
 
   'On exécute l'action Submit de la Form
    FormGoogleCherche.submit
 
   'On attend le chargement complet de la page
   WaitIE IE
 
   Set IEDoc = IE.document
 
    DoEvents
 
  Set tables = IE.document.all.tags("table")
  SetDataFromWebTable tables, Range("A1")
  IE.Quit
End Sub
 
Sub SetDataFromWebTable(webTables, startRange As Range)
On Error GoTo ErrorHandler
 
 
For Each webTable In webTables
 
    Dim trs, tr, tds, td, r, c
 
        Set trs = webTable.getElementsByTagName("tr")
 
        For r = 0 To trs.Length - 1
            Set tds = trs(r).getElementsByTagName("td")
 
            If tds.Length = 0 Then Set tds = trs(r).getElementsByTagName("th")
 
            For c = 0 To tds.Length - 1
                startRange.Offset(r, c).Value = tds(c).innerText
            Next c
        Next r
        ' table is inserted by rows
        Set startRange = startRange.End(xlDown).Offset(2, 0)
Next webTable
 
ErrorHandler:
Exit Sub
 
End Sub
Le Fichier source

Code html : Sélectionner tout - Visualiser dans une fenêtre à part
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<!-- saved from url=(0055)http://10.176.36.20/waf/MissingReportSelectionFilter.do -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Généré par Outils de développement. Il est possible que ce ne soit pas une représentation précise du fichier source original -->
<HTML><HEAD><TITLE>Rapports</TITLE><LINK rel=stylesheet type=text/css href="/waf/include/css/styles.css"><LINK rel="shortcut icon" href="/waf/include/images/favicon.ico">
<STYLE type=text/css media=screen>#content #dataview TH.align {
	TEXT-ALIGN: right
}
.align {
	TEXT-ALIGN: right
}
#hname {
	DISPLAY: none; VISIBILITY: hidden
}
#next {
	DISPLAY: none; VISIBILITY: hidden
}
#prev {
	DISPLAY: none; VISIBILITY: hidden
}
#info {
	HEIGHT: 20px
}
INPUT.mediumtext {
	WIDTH: 188px; MARGIN-RIGHT: 5px
}
</STYLE>
 
<STYLE type=text/css media=print>#sidebar {
	DISPLAY: none; VISIBILITY: hidden
}
#header {
	DISPLAY: none; VISIBILITY: hidden
}
#navbar {
	DISPLAY: none; VISIBILITY: hidden
}
#headerdropshadow {
	DISPLAY: none; VISIBILITY: hidden
}
#footer {
	DISPLAY: none; VISIBILITY: hidden
}
#breadcrumbs {
	DISPLAY: none; VISIBILITY: hidden
}
#browse {
	DISPLAY: none; VISIBILITY: hidden
}
#hname {
	TEXT-ALIGN: left; WIDTH: 100%; DISPLAY: inline; VISIBILITY: visible
}
#content #dataview TH.align {
	TEXT-ALIGN: right
}
.align {
	TEXT-ALIGN: right
}
</STYLE>
</HEAD>
<BODY>
<DIV id=header>
<P class=vilsgheaderlogo><IMG border=0 alt="Industries" > </P>
<P class=sysuheaderlogo><A href="/waf/Index.do?pageId=1&amp;ticket=10"><IMG border=0 alt=VISION > </A></P></DIV>
<DIV id=navbar>
<P>jeudi, 02 février 2017 </P>
<P class=message></P>
<UL>
<LI><A href="/waf/Index.do?pageId=1&amp;ticket=10">Accueil</A> </LI>
<LI><A href="/waf/Backward.do?pageId=1&amp;ticket=10">Retour</A> </LI>
<LI><A href="/waf/Refresh.do?drillLevel=0&amp;pageId=1&amp;ticket=10">Rafraichir</A> </LI>
<LI><A href="javascript:window.print ()">Imprimer</A> </LI>
<LI><A href="/waf/protected/system/process/events.jsp?pageId=1&amp;ticket=10">Evénements</A> </LI>
<LI><A href="/waf/LogoutProxy?pageId=1&amp;ticket=10">Sortir</A> </LI></UL></DIV>
<DIV id=headerdropshadow></DIV>
<H2 id=breadcrumbs><A href="/waf/Index.do?pageId=1&amp;ticket=10">Accueil</A> » Rapports Attendus </H2>
<TABLE id=pagecontainer>
<TBODY>
<TR>
<TD id=sidebarcontainer>
<DIV id=sidebar>
<H3>Filtre</H3>
<DIV class=filterbox>
<FORM method=post name=missingReportSelectionFilterForm action=/waf/MissingReportSelectionFilter.do><INPUT value=1 type=hidden name=pageId><INPUT value=10 type=hidden name=ticket> <INPUT value=1 type=hidden name=drillLevel> 
<DL>
<DT>Num 
<DD><SELECT size=1 name=waveID> <OPTION value="">Séléctionner</OPTION> <OPTION selected>4101</OPTION></SELECT> 
<DT>Type Rapport 
<DD><SELECT name=reportType><OPTION selected value=Items>Réference(Sku)</OPTION> <OPTION value=Store>Mag</OPTION></SELECT> <INPUT accessKey=s class=button title="* Message:#ApplyFilterHint *" value=Selectionner type=submit> </DD></DL></FORM></DIV></DIV></TD>
<TD id=contentcontainer>
<DIV id=content>
<H3 id=hname>4101<BR><BR></H3>
<TABLE id=dataview>
<TBODY>
<TR>
<TH><A href="/waf/SelectViewAction.do?drillLevel=2&amp;columnName=SkuId&amp;method=sort&amp;resultSetName=MissingItemsReport&amp;pageId=1&amp;ticket=10">Réference(Sku)</A></TH>
<TH><A href="/waf/SelectViewAction.do?drillLevel=2&amp;columnName=SkuName&amp;method=sort&amp;resultSetName=MissingItemsReport&amp;pageId=1&amp;ticket=10">Libellé</A></TH>
<TH><A href="/waf/SelectViewAction.do?drillLevel=2&amp;columnName=Missing&amp;method=sort&amp;resultSetName=MissingItemsReport&amp;pageId=1&amp;ticket=10">Colis</A></TH></TR>
<TR>
<TD>000000229400</TD>
<TD>GROS PAIN</TD>
<TD>7</TD></TR>
<TR class=pattern>
<TD>000000359800</TD>
<TD>MN BATON ENVIE CHOC</TD>
<TD>3</TD></TR>
<TR>
<TD>000001703500</TD>
<TD>PAIN POLKA ROND</TD>
<TD>3</TD></TR>
<TR class=pattern>
<TD>000001798700</TD>
<TD>POM RISSOLEES HERBE</TD>
<TD>4</TD></TR>
<TR>
<TD>000001833300</TD>
<TD>EPINARDS</TD>
<TD>26</TD></TR>
<TR class=pattern>
<TD>000002537800</TD>
<TD>CARTE D OR CITRON</TD>
<TD>3</TD></TR>
<TR>
<TD>000002551010</TD>
<TD>PATE BOTTEREAUX</TD>
<TD>11</TD></TR>
<TR class=pattern>
<TD>000003714100</TD>
<TD>PANIER JBON/FROMAGE</TD>
<TD>21</TD></TR>
<TR>
<TD>000004163700</TD>
<TD>CONES RHUM/RAISINS</TD>
<TD>1</TD></TR>
<TR class=pattern>
<TD>000004274400</TD>
<TD>NOUGAT FRUITS</TD>
<TD>2</TD></TR>
<TR>
<TD>000005019000</TD>
<TD>ROSTI AUX OIGNON</TD>
<TD>7</TD></TR>
<TR class=pattern>
<TD>000005306500</TD>
<TD>PAELLA FRT</TD>
<TD>14</TD></TR>
<TR>
<TD>000005909900</TD>
<TD>BATONNETS VAN/PISTA</TD>
<TD>1</TD></TR>
<TR class=pattern>
<TD>000005913500</TD>
<TD>BATONNETS</TD>
<TD>1</TD></TR>
<TR>
<TD>000005917000</TD>
<TD>BATONNETS </TD>
<TD>1</TD></TR>
<TR class=pattern>
<TD>000005920700</TD>
<TD>BATONNETS VANILL</TD>
<TD>1</TD></TR>
<TR>
<TD>000006098400</TD>
<TD>TRANCHE FLT</TD>
<TD>9</TD></TR>
<TR class=pattern>
<TD>000006127100</TD>
<TD>SAUMON</TD>
<TD>3</TD></TR>
<TR>
<TD>000006821700</TD>
<TD>PALMIER</TD>
<TD>1</TD></TR>
<TR class=pattern>
<TD>000006821710</TD>
<TD>PALMIER</TD>
<TD>9</TD></TR>
<TR>
<TD>000006901900</TD>
<TD>CREME GLACE</TD>
<TD>1</TD></TR>
<TR class=pattern>
<TD>000006918600</TD>
<TD>GLACE VANIL/PEC</TD>
<TD>2</TD></TR>
<TR>
<TD>000007399900</TD>
<TD>CALAMARS</TD>
<TD>7</TD></TR>
<TR class=pattern>
<TD>000007674500</TD>
<TD>PIZZA FRAICHUP</TD>
<TD>11</TD></TR>
<TR>
<TD>000007686900</TD>
<TD>HAR VER TR</TD>
<TD>7</TD></TR>
<TR class=pattern>
<TD>000007724800</TD>
<TD>BATONNET POIS</TD>
<TD>11</TD></TR>
<TR>
<TD>000007984800</TD>
<TD>COQ ST JACQ BRET</TD>
<TD>4</TD></TR>
<TR class=pattern>
<TD>000008088610</TD>
<TD>MERVEILLE VRAC</TD>
<TD>14</TD></TR>
<TR>
<TD>000008639100</TD>
<TD>JUST AU FOUR ALLUM</TD>
<TD>7</TD></TR>
<TR class=pattern>
<TD>000008675800</TD>
<TD>CRAQ FTS RG/PASSION</TD>
<TD>3</TD></TR>
<TR>
<TD>000008836710</TD>
<TD>BUGN VRAC</TD>
<TD>30</TD></TR>
<TR class=pattern>
<TD>000009118900</TD>
<TD>GLACE CARAMEL</TD>
<TD>2</TD></TR>
<TR>
<TD>000009308400</TD>
<TD>MINI P RAISIN</TD>
<TD>4</TD></TR>
<TR class=pattern>
<TD>000009308410</TD>
<TD>MINI P RAISIN</TD>
<TD>3</TD></TR>
<TR>
<TD>000009838800</TD>
<TD>EPINARDS HACHES</TD>
<TD>19</TD></TR>
<TR class=pattern>
<TD>000010174500</TD>
<TD>MINI P CHOCO</TD>
<TD>4</TD></TR>
<TR>
<TD>000010174510</TD>
<TD>MINI P CHOCO</TD>
<TD>3</TD></TR>
<TR class=pattern>
<TD>000010181200</TD>
<TD>MINI CROISS</TD>
<TD>4</TD></TR>
<TR>
<TD>000010181210</TD>
<TD>MINI CROISS 25G </TD>
<TD>3</TD></TR>
<TR class=pattern>
<TD>000010598800</TD>
<TD>QUICHE LORRAINE</TD>
<TD>27</TD></TR>
<TR>
<TD>000011518500</TD>
<TD>BAT COLIN ALASKA </TD>
<TD>14</TD></TR>
<TR class=pattern>
<TD>000011828100</TD>
<TD>P RAISINS FEUIL </TD>
<TD>7</TD></TR>
<TR>
<TD>000011936900</TD>
<TD>TARTEL TATIN</TD>
<TD>2</TD></TR>
<TR class=pattern>
<TD>000012430500</TD>
<TD>CREPE JAMBON/FROMAGE</TD>
<TD>38</TD></TR>
<TR>
<TD>000012434700</TD>
<TD>CREPE JAMBON/FROMAGE</TD>
<TD>44</TD></TR>
<TR class=pattern>
<TD>000773460100</TD>
<TD>LES LEG VRTS</TD>
<TD>1</TD></TR>
<TR>
<TD>000773869500</TD>
<TD>ASSOR PR CAFE</TD>
<TD>1</TD></TR></TBODY></TABLE>
<TABLE id=browse>
<TBODY>
<TR>
<TD id=prev>précédent</TD>
<TD id=info>Numero Page</TD>
<TD id=next><A href="/waf/SelectViewAction.do?drillLevel=2&amp;method=forward&amp;resultSetName=MissingItemsReport&amp;pageId=1&amp;ticket=10">Suivant</A></TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE>
<DIV id=footer>
</DIV></BODY></HTML>
Merci d'avance pour vos réponses.

Rapports.html