Convert from Excel to HTML?

Author
Discussion

theboyfold

Original Poster:

10,922 posts

227 months

Sunday 14th November 2010
quotequote all
What's the easiest way to convert files from Excel spreadsheets to HTML? I know you can do it from with Excel, but I will have lots of files so ideal I'd like a (ideally free) bit of software to do.

theboyfold

Original Poster:

10,922 posts

227 months

Monday 15th November 2010
quotequote all
Nobody? frown

JontyR

1,915 posts

168 months

Tuesday 16th November 2010
quotequote all
Macro?

lestag

4,614 posts

277 months

Tuesday 16th November 2010
quotequote all
can't vouch for any of tehm , but google found these
http://www.google.co.nz/search?q=convert+excel+to+...

Jinx

11,394 posts

261 months

Tuesday 16th November 2010
quotequote all
Save file as "single web page" mhtml in the save as option?

JontyR

1,915 posts

168 months

Tuesday 16th November 2010
quotequote all
Jinx said:
Save file as "single web page" mhtml in the save as option?
I think this is the idea of not doing it manually because of having many files to work with!

theboyfold

Original Poster:

10,922 posts

227 months

Tuesday 16th November 2010
quotequote all
lestag said:
can't vouch for any of tehm , but google found these
http://www.google.co.nz/search?q=convert+excel+to+...
Thanks, I've had a look through most of them but they all seem to shareware or restricted in some way.

JontyR said:
Jinx said:
Save file as "single web page" mhtml in the save as option?
I think this is the idea of not doing it manually because of having many files to work with!
Exactly! I could end up with a few hundred to work my way through.

JontyR

1,915 posts

168 months

Tuesday 16th November 2010
quotequote all
Have you any experience with VBA?

If you create a folder called Test in the C drive, throw a few of the spreadsheets into it.
You will need to open up a Excel window and go into the code area, copy the code run it.

Let me know what you get.


Option Explicit

Private Const cmsPath As String = "C:\Test\"
Private Const cmbSubFolders As Boolean = True

Private Sub SaveFiles()
Dim oFsys As Object
Dim oFile As Object
Dim oParentFol As Object, oFol As Object
Dim oWb As Workbook, oWs As Worksheet
Dim sNew As String

Set oFso = CreateObject("Scripting.FileSystemObject")
Set oParentFol = oFsys.GetFolder(cmsPath)

For Each oFile In oParentFol.Files
If LCase(Right(oFile.Name, 3)) = "xls" Then
Set oWb = Workbooks.Open(Filename:=oFile.Path)
sNew = oFile.Path
sNew = Left(sNew, Len(sNew) - 3) & "htm"
For Each oWs In oWb.Worksheets
oWb.PublishObjects.Add(SourceType:=xlSourceSheet, Filename:=sNew, Sheet:=oWs.Name, HtmlType:=xlHtmlStatic, DivID:=Left(oFile.ShortName, Len(oFile.ShortName) - 4) & "_" & oWs.Name).Publish
Next oWs
oWb.Close SaveChanges:=False
Set oWb = Nothing
End If
Next oFile


End Sub

TonyToniTone

3,425 posts

250 months

Tuesday 16th November 2010
quotequote all
You could try this vbscript it has no error checking but should work..



Dim fso, f, Files, FileColl
Const xlHTML = 44
Set objExcel = CreateObject("Excel.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("d:\testdir")
Set FileColl = f.Files

For Each Files in FileColl
Set objWorkBook = objExcel.Workbooks.Open(Files.parentfolder & "\" & Files.name )
objWorkBook.SaveAs Files.parentfolder & "\" & Replace(Files.name,"xls","html") , xlHtml
objWorkBook.Close True
Next