lundi 29 avril 2019

How to cast a whole html body with .CSV format to an Excel sheet with VBA

How to grab the whole body of an html document accessed through a macro with IE as an object.

I have a working VB code that goes into an internal enterprise site and pulls a report as expected, the problem is that the report is a .CSV table in the HTML body, nothing else, only the table, I guess for security matters there's no download button (as a matter of fact this .csv format only works with admin privileges, a radio button is checked for .csv report to be displayed), so, the idea is that the macro goes into the report, creates the report and then grabs this info and puts it in a sheet on range A1.

The url looks like this:

http://teamadmin.mycompany.com/teams/repmemc.php?mode=1&group=Team&format=csv&attr%5B%5D=uid&attr%5B%5D=mail&attr%5B%5D=givenname&attr%5B%5D=sn

If I use the tool: DATA>From Web it works fine and gets the csv into the sheet, but when I try to automatize I no positive results.

The html code of the website containing the table looks like this:

<html>
<head></head>
<body>
</br>
"Saxon, Joseph",123,jsaxon@mycompany.com,Joseph,Saxon
</br>
"Carillo, Yul",456,ycarillo@mycompany.com,Yul,Carillo
</br>
"wilmier, omuaus",789,owilimier@mycompany.com,Omaus,Wilmier
</br>
"Kelly, Brandon",101,bkelly@mycompany.com,Brandon,Kelly
</br>
"Skien, Thomas",112,tskien@mycompany.com,Thomas,Skien
</br>
"Pereis, Adriano",131,apereis@mycompany.com,Adriano,Pereis
</br>
"Lans, Carinemer",411,clans@mycompany.com,Carinemer,Lans
</br>
"Sampson, Odimi",511,osampson@mycompany.com,Odimi, Sampson
</br>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire