Converting HTML to Excel?

Saicharan S M picture Saicharan S M · Mar 5, 2012 · Viewed 205.5k times · Source

I know that Excel is capable of opening HTML files directly. But the content of the file will still be HTML. Is there any way I can change the contents of the file from HTML to XLS or XLSX?

Answer

Robert Mearns picture Robert Mearns · Mar 6, 2012

So long as Excel can open the file, the functionality to change the format of the opened file is built in.

To convert an .html file, open it using Excel (File - Open) and then save it as a .xlsx file from Excel (File - Save as).

To do it using VBA, the code would look like this:

Sub Open_HTML_Save_XLSX()

    Workbooks.Open Filename:="C:\Temp\Example.html"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Temp\Example.xlsx", FileFormat:= _
        xlOpenXMLWorkbook

End Sub