Saving Excel Sheet as an HTML file

I have an excel workbook with many sheets.  I'm looking for some vba code to save one of the sheets (sheet is named Schedule) as an HTML file.  The code will need to be able to save over the existing html file that is already in the folder.  Thank you
jnikodymAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

regmigrantCommented:
I'm assuming you tried the obvious and its not doing what you expect?

 
ActiveWorkbook.SaveAs Filename:= _
        "C:\My Documents\myfile.mht", FileFormat:= _
        xlWebArchive, CreateBackup:=False

Open in new window


If the problem is the overwrite warning try adding
Application.DisplayAlerts = False

Open in new window


before the Save as and
Application.DisplayAlerts = True

Open in new window

afterwiord

Otherwise please let me know the problem
0
jnikodymAuthor Commented:
I think i misspoke on what i need to do.  I have the excel file named file.xls.  What i want to do is i guess export the file to a .mht file, but i still want to be working on the file.xls file after the .mht file is saved.  Does that make sense?  With the above code it is a save as and then i am working on the .mht file.
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You may try something like this.....
This is what I recorded while performing your task.

With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
    "C:\Users\sktneer\Desktop\file.mht", "Schedule", "", xlHtmlStatic, "file_29420" _
    , "")
    .Publish (True)
    .AutoRepublish = False
End With

Open in new window

Where file is the name of your workbook (file.xlsx) and Schedule is the name of the sheet.

Does this help.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.