Save As Web Page Automation Help

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Please be kind, I'm just starting to learn to program
Excel.

I've tried automating the "save as web page" process by
recording a macro, but it's not working.

I would like to place a button on the worksheet so that a
press of the button will save it as a web page to a
defined location/filename.

I have everything ready to go, except the code. Recording
macros didn't help.

Thx
 
Hi Steve

Try this to save the activesheet as a htm file

Sub test()
Dim sName As String
sName = "C:\test.htm"

ActiveWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=sName, _
Sheet:=ActiveSheet.Name, _
Source:=ActiveSheet.UsedRange.Address, _
HtmlType:=xlHtmlStatic).Publish
End Sub
 
Ron de Bruin said:
Hi Steve

Try this to save the activesheet as a htm file

Sub test()
Dim sName As String
sName = "C:\test.htm"

ActiveWorkbook.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=sName, _
Sheet:=ActiveSheet.Name, _
Source:=ActiveSheet.UsedRange.Address, _
HtmlType:=xlHtmlStatic).Publish
End Sub
 
Back
Top