an Excel VBA of my codes...
'**********************************************************
Sub htmlPublishObjects()
Dim wSheet As Worksheet, wBook As Workbook
MyPath = "C:\tEMP\d\*.xls" ' Set the path.
MyName = Dir(MyPath) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
Workbooks.Open Filename:=MyName, UpdateLinks:=3
Set wSheet = Application.ActiveSheet
Set wBook = Application.ActiveWorkbook
Call wSheet.Unprotect("myProtectionPssw"
ActiveWorkbook.PublishObjects.Add(xlSourceSheet, "C:\tEMP\d\" & _
Left(wBook.Name, Len(wBook.Name) - 3) & "htm", _
"MyTitle", "", xlHtmlStatic, "1wu", "".Publish (True)
wBook.Close False
MyName = Dir ' Get next entry.
Loop
End Sub
This logic works perfectly if we have only on sheet in excel workbook. I have multiple sheets in excel file. When we convert this excel file to HTML all the sheets should apprear in the same HTML file. I tried to loop through all the sheets and convert to HTML. The problem is it overwrites the same HTML file instead of adding tabs in same html file.
Any suggestions ?
Dim wSheet As Worksheet
Dim wBook As Workbook
MyName = "C:\testing\Temp.xls"
Workbooks.Open FileName:=MyName, UpdateLinks:=3
Set wBook = Application.ActiveWorkbook
For iLoop1 = 1 To wBook.Application.Sheets.Count
Set xlSheet = wBook.Application.Sheets(iLoop1)
Call xlSheet.Unprotect("myProtectionPssw"
ActiveWorkbook.PublishObjects.Add(xlSourceSheet, "C:\testing\Temp.htm", xlSheet.Name, "", xlHtmlStatic, "1wu", "".Publish (True)
Set xlSheet = Nothing
Next iLoop1
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.