Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save HMTL as excel

Status
Not open for further replies.

NHSSAS

Programmer
Mar 19, 2010
4
GB
Hi,

I have approximately 80 HMTL files that I need to convert to excel files. I can come up with code to open the HTML and save it again but ending in .xls instead of .html (see below) but I would have to input this code for every HTML file. Is there a way to do this for all 80 files in one go without repeating this code?

Many thanks!

Application.DisplayAlerts = False
Workbooks.Open Filename:="filepath\file a.html"
ChDir _
"filepath"
ActiveWorkbook.SaveAs Filename:= _
"filepath\file a.xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close False
 
Dim strFile As String
Application.DisplayAlerts = False
strFile = Dir("filepath\*.html")
While strFile <> ""
Workbooks.Open Filename:="filepath\" & strFile
ActiveWorkbook.SaveAs Filename:= _
"filepath\" & Left(strFile, Len(strFile) - 4) & "xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close False
strFile = Dir()
WEnd
Application.DisplayAlerts = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top