Bonjour à tous,
Je cherche à importer une page html dans Excel (ou dans un fichier texte que je pourrais traiter avec Excel). J'ai vu que cela était possible en utilisant l'objet querytables. Le code suivant fonctionne:
Dim qt As QueryTable
Dim sh As Worksheet
'
Set sh = ThisWorkbook.Worksheets("Feuil5")
Set qt = sh.QueryTables _
.Add(Connection:="URL;http://www.google.fr", _
Destination:=sh.Cells(1, 1))
With qt
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1"
.Refresh
End With
Mais pas sur la page avec laquelle je souhaite travailler:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0038)http://xxxxxxxxx/server/JOBLOG.htm -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY text=#000000 vLink=#0000ff aLink=#00ff00 link=#0000ff bgColor=#ffffff>
<CENTER>
<H1>blablablabla</H1>
<HR width="90%">
<H2>Print Job Log</H2>System Up Time: 03 days 05 hours 53 mins 55 secs<BR><BR>
<TABLE cellSpacing=6 cellPadding=3 align=center border=0>
<TBODY>
<TR>
<TH noWrap align=middle>Total Jobs Printed:</TH>
<TD noWrap>1859</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 16
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 6 minutes 11 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 20
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 6 minutes 11 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 22
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 6 minutes 12 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 20
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 6 minutes 13 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 16
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 12 minutes 38 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 20
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 12 minutes 39 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 22
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 12 minutes 40 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 20
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 12 minutes 40 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 1491830
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 13 minutes 22 seconds</TD></TR>
<TR>
<TH noWrap align=right>Job Information:</TH>
<TD noWrap>TCP/IP * IP Address xxxxxxxxx * TCP Port 9100 * 20
Bytes</TD></TR>
<TR>
<TH noWrap align=right>Time Elapsed:</TH>
<TD noWrap>0 hours 14 minutes 36 seconds</TD></TR></TBODY></TABLE><BR>
<HR width="90%">
<BR>
<CENTER><A href="xxxxxxxxx" target=_top>| Home
|</A><A href="xxxxxxxxx" target=_top> Print Server
Config |</A> <BR></CENTER></CENTER></BODY></HTML>
J'obtiens le message d'erreur :
Aucune donnée renvoyée par la requête Web. Pour modifier la requête...
Je travail beaucoup sur les fichiers en vba (FileSystemObject). Si il y a moyen d'enregistrer une page web (fichier enregistrer sous depuis un browser) en VBA ça serait idéal.
Merci pour votre aide