Reputation: 101
I have a requirement where I need to save only result sheet as html file so that I can attach it and email using vb scripting. I tried the following code but it changes even the name of the spreadsheet to the target html file name. Also, I need to save just one sheet as html and not all the sheets.
ThisWorkbook.Sheets("Result").SaveAs "C:\Work\Result.html", xlHtml
Upvotes: 0
Views: 705
Reputation: 166196
If you record a macro while exporting just the selected range to HTML you'll get something like this, which you can then modify to suit your needs:
Range("B3:C23").Select
With ActiveWorkbook.PublishObjects.Add(xlSourceRange, _
"C:\Book1.htm" _
, "Sheet2", "$B$3:$C$23", xlHtmlStatic, "Book1_7762", "Export")
.Publish (True)
.AutoRepublish = False
End With
Upvotes: 1