vba 将 Excel 工作表另存为 html 文件,类似于手动另存为
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25925846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Save Excel sheet as html file similar to manual save as
提问by Steve S
I have a multiple sheet Excel workbook. I want to save one sheet as a html file using VBA.
我有一个多页 Excel 工作簿。我想使用 VBA 将一张工作表另存为 html 文件。
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.
它应该类似于另存为操作。进行手动另存为格式显示在保存的 HTML 文件中时。使用 VBA 时,格式会丢失。
Application.Sheets("MNM Report").Activate
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:="D:\Reports192014\mnm.html"
How to do this functionality with out losing the formatting?
如何在不丢失格式的情况下执行此功能?
回答by Steve S
Try using the FileFormat
argument of the Workbook.SaveAs
Method. E.g.
尝试使用方法的FileFormat
参数Workbook.SaveAs
。例如
ActiveWorkbook.SaveAs Filename:="D:\Reports192014\mnm.html" FileFormat:=xlHtml
You can see more options for FileFormat
in the XlFileFormat Enumerationfrom MSDN.
您可以FileFormat
在MSDN的 XlFileFormat 枚举中看到更多选项。