Saving 2 worksheets as .html from the same workbook

Bub_the_Zombie

Board Regular
Joined
Nov 1, 2016
Messages
53
Hey everyone have a few advanced questions I need explained in semi-lay person speak.

I have made a excel Workstation (in .xlsm) that handles everything I need to do during the day (thank you to everyone here that helped me with my pile of questions to complete it). On the workstation there are two worksheets that will be saved as two .html files so they can be displayed on two separate monitors.

I am saving the worksheet by
save as > Save as type: Web Page (*.htm:*.html) > Save: Selection: Sheet > Publish > (Choose the required sheet) > AutoRepublish every time this workbook is saved

Questions / problems.
1. When I save the workbook it is not updating the .html file, am I missing a step somewhere?

2. Is it possible to save two .html files from the same workbook? Meaning when I save the original workbook will both the worksheets update save correctly? Or do I need to create individual workbooks for each .html file I wish to create?

3. Is there any other problems I should keep an eye out for?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I am saving the worksheet by
save as > Save as type: Web Page (*.htm:*.html) > Save: Selection: Sheet > Publish > (Choose the required sheet) > AutoRepublish every time this workbook is saved
Questions / problems.
1. When I save the workbook it is not updating the .html file, am I missing a step somewhere?

By updating, do you mean that the original HTML file is not being overwritten with the new one?

2. Is it possible to save two .html files from the same workbook? Meaning when I save the original workbook will both the worksheets update save correctly? Or do I need to create individual workbooks for each .html file I wish to create?

You might want to look into running a macro every time the workstation workbook closes. If you do then you can make a macro to save and overwrite your existing HTML documents with new ones.
What I have below is a macro I recorded using the actions above you listed in saving an HTML document. From there I created a macro that runs everytime the workbook closes which activates the save HTML macro.

Place this code inside a module of the workbook
Code:
Sub Macro1()
'
' Macro1 Macro
'


'
    Dim pth as String
    pth = "C:\" 'YOUR LOCATION
    With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
        pth & "\Book1.htm", "Sheet1", "", xlHtmlStatic, _
        "Book1_23835", "Sheet1")
        .Publish (True)
        .AutoRepublish = True
    End With
    ChDir pth
End Sub

and place this code in the 'ThisWorkbook' sheet of the Visual Basic Editor section
Code:
Public WithEvents App as Application

Private Sub App_WorkbookBeforeClose(ByVal wb As Workbook, cancel As Boolean)
    Macro1
End Sub

3. Is there any other problems I should keep an eye out for?

You might run into some issues if the file is already opened, which will cause you will error out when trying to overwrite that file. To combat this look into Error handling.
 
Last edited:
Upvote 0
Thanks! Will give it a try.

I just retried my original set up and it seems to be working. The IT guy at work set it up the first time and it stopped working, I redid it changed the file name and it is working.
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top