Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Office 2007 Excel Macro to save Active Worksheet to HTML by name

I have run through the Macro recorder and saved this macro to convert
an existing worksheet to HTLM in a specific file share. What I am
trying to do is save the 'active' worksheet. I have a multi-sheet
workbook, and I need to publish each sheet as it's name to an HTML
file. I can make it work with individual macros, but I can't get a
macro to detect the active sheet and use it's name as the HTML file:

'************** Start Code
Sub TestToHtml()
'
' TestToHtml Macro
' TestDescription
' Keyboard Shortcut: Ctrl+m
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Users\daviller\Documents\temp.htm", "C", "", xlHtmlStatic,
"temp_26389", "" _
)
.Publish (True)
.AutoRepublish = False
End With
End Sub

'********************* End Code

I've tried replacing the "C" (worksheet name) with activesheet.name
and other variations, but none of this works. any help would be
greatly appreciated. my end game is to have a macro that my users can
Ctrl+e and it publishes an HTML file to a specific directory based on
the worksheet name.

Cheers++
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Office 2007 Excel Macro to save Active Worksheet to HTML by name


Sub AllSheets()
Const HTML_PATH As String = "C:\Users\daviller\Documents\<sheet.htm"

Dim s As Worksheet
For Each s In ActiveWorkbook.Worksheets
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
Replace(HTML_PATH, "<sheet", s.Name), _
s.Name, "", xlHtmlStatic, "temp_26389", "")
.Publish (True)
.AutoRepublish = False
End With
Next s

End Sub

Tim


"daviller" wrote in message
...
I have run through the Macro recorder and saved this macro to convert
an existing worksheet to HTLM in a specific file share. What I am
trying to do is save the 'active' worksheet. I have a multi-sheet
workbook, and I need to publish each sheet as it's name to an HTML
file. I can make it work with individual macros, but I can't get a
macro to detect the active sheet and use it's name as the HTML file:

'************** Start Code
Sub TestToHtml()
'
' TestToHtml Macro
' TestDescription
' Keyboard Shortcut: Ctrl+m
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Users\daviller\Documents\temp.htm", "C", "", xlHtmlStatic,
"temp_26389", "" _
)
.Publish (True)
.AutoRepublish = False
End With
End Sub

'********************* End Code

I've tried replacing the "C" (worksheet name) with activesheet.name
and other variations, but none of this works. any help would be
greatly appreciated. my end game is to have a macro that my users can
Ctrl+e and it publishes an HTML file to a specific directory based on
the worksheet name.

Cheers++
David



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Office 2007. Save HTML phil j. Excel Discussion (Misc queries) 1 January 3rd 10 03:21 PM
Is Paste Special HTML broken in Excel/Office 2007? new2money Excel Discussion (Misc queries) 1 December 18th 08 11:42 PM
save excel 2007 worksheet as pdf in macro Jania Excel Programming 2 September 29th 08 03:16 PM
Excel 2007 Save As HTML? leonbip Excel Discussion (Misc queries) 1 August 17th 07 02:22 AM
Excel 2007 Save As HTML? Duke Carey Excel Discussion (Misc queries) 0 August 17th 07 02:00 AM


All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"