Home » excel » Saving excel file to html format generates many sheetXXX.htm

Saving excel file to html format generates many sheetXXX.htm

Posted by: admin May 14, 2020 Leave a comment


I want to save complex Excel file to html format. It can be easily done with Save As dialog, but it generates htm file and folder with same name + .files, where is filelist.xml, sheet001.htm, sheet002.htm, …

How can I save only first sheet to htm format? So all the information lies in single htm file?(Like MS Word do)

How to&Answers:

Delete the other sheets before exporting.

(right click on the sheet tab and click delete)

When saving change the selection to web page and select the selection:sheet button press publish and continue as appropriate.


What you can do is copy the sheets you want to save as HTML to a new workbook and save that new workbook as HTML instead. For example:

Public Sub doIt()

    saveFile "C:\temp\fileName.html"

End Sub

Private Sub hardCopyToNewBook()

  Dim tabs As Variant
  Dim s As Worksheet

  tabs = Array("Sheet1", "Sheet2")

  For Each s In ActiveWorkbook.Sheets
    With s
      .Cells.PasteSpecial Paste:=xlPasteValues
    End With
  Next s

  Application.CutCopyMode = False

End Sub

Private Sub saveFile(htmlFileName As String)

  Application.DisplayAlerts = False
  Application.DefaultWebOptions.SaveHiddenData = False

  On Error Resume Next
  Call ActiveWorkbook.SaveAs(fileName:=htmlFileName, FileFormat:=xlHtml)
  Application.DisplayAlerts = True

End Sub


Found Solution – there is radio button to save only selected sheets