user3670700
user3670700

Reputation:

Save Excel sheet as html file similar to manual save as

I have a multiple sheet Excel workbook. I want to save one sheet as a html file using VBA.

It should be like the save as operation. When doing a manual save as the formatting is displaying in the saved HTML file. When using VBA the formatting is lost.

Application.Sheets("MNM Report").Activate
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:="D:\Reports\09192014\mnm.html"

How to do this functionality with out losing the formatting?

Upvotes: 2

Views: 16808

Answers (1)

Steve S
Steve S

Reputation: 431

Try using the FileFormat argument of the Workbook.SaveAs Method. E.g.

ActiveWorkbook.SaveAs Filename:="D:\Reports\09192014\mnm.html" FileFormat:=xlHtml

You can see more options for FileFormat in the XlFileFormat Enumeration from MSDN.

Upvotes: 3

Related Questions