求教VB将excel转换为网页文件的代码!
各位老师跪求一段VB将某个文件夹里面的文件,excel转换为网页文件的代码,网上很少介绍这方面的内容,找到一行代码看不懂。
xlSheet.SaveAs FileName:="c:/te.htm",FileFormat:=xlHtml
请各位路过老师指点一下。谢谢!
程序代码:Private Sub Command1_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim sFile As String
XlsxDir = App.Path & "\w\"
HtmlDir = App.Path & "\w\html\" '必须已存在
'XlsxDir = "d:\Documents\Desktop\tt\"
'HtmlDir = "d:\Documents\Desktop\tt\html\" '必须已存在
sFile = Dir(XlsxDir)
Do While (Not sFile = "")
Debug.Print (XlsxDir & sFile)
Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象
Set xlBook = xlApp.Workbooks.Open(XlsxDir & sFile) '打开Excel文件
xlBook.SaveAs HtmlDir & sFile & ".html", Excel.XlFileFormat.xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False '保存html文件
xlBook.Close (False) '关闭Excel文件
Set xlBook = Nothing
xlApp.Quit '结束EXCEL对象
Set xlApp = Nothing '释放xlApp对象
sFile = Dir()
DoEvents
Loop
Debug.Print ("OK")
End Sub