Reputation: 10376
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)
Upvotes: 1
Views: 5104
Reputation: 328598
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()
hardCopyToNewBook
saveFile "C:\temp\fileName.html"
End Sub
Private Sub hardCopyToNewBook()
Dim tabs As Variant
Dim s As Worksheet
tabs = Array("Sheet1", "Sheet2")
Sheets(tabs).Copy
For Each s In ActiveWorkbook.Sheets
With s
.Cells.Copy
.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)
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
Upvotes: 1
Reputation: 10376
Found Solution - there is radio button to save only selected sheets
Upvotes: 0
Reputation: 1654
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.
Upvotes: 2