Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Save a single file webpage of each visible sheet in a workbook

I am trying to write a macro that will save a copy of all visible sheets in
my workbook as single file webpages - .mht (one .mht file per sheet).

I have written the following which automatically publishes a single file
webpage for the current sheet but I have no idea how to generalise it to work
on all visible sheets. Can anyone Help?

Sub SaveSFWP()

Application.ScreenUpdating = False
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text & "
Departure.mht", "Sheet1", "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
ChDir "C:\Documents and Settings\MatthewA\Desktop"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Save a single file webpage of each visible sheet in a workbook

Hi Matt

You can adapt this example
http://www.rondebruin.nl/copy6.htm

--
Regards Ron De Bruin
http://www.rondebruin.nl



"Matt" wrote in message ...
I am trying to write a macro that will save a copy of all visible sheets in
my workbook as single file webpages - .mht (one .mht file per sheet).

I have written the following which automatically publishes a single file
webpage for the current sheet but I have no idea how to generalise it to work
on all visible sheets. Can anyone Help?

Sub SaveSFWP()

Application.ScreenUpdating = False
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text & "
Departure.mht", "Sheet1", "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
ChDir "C:\Documents and Settings\MatthewA\Desktop"
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Save a single file webpage of each visible sheet in a workbook

Thanks Ron,

I have used your example and changed my marco to the following:

Sub SaveMHTv2()

Application.ScreenUpdating = False
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = True Then
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text
& ActiveSheet.Name & ".mht", ActiveSheet.Name, "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
End If
Next sh

ChDir "C:\Documents and Settings\MatthewA\Desktop"

Application.ScreenUpdating = True

End Sub

Unfortunately it is still only saving the first sheet of the workbook as a
single file webpage. I think it is due to the With statement that I am using.

Any idea why it is not running on all the visible sheets?

Thanks

Matt



"Ron de Bruin" wrote:

Hi Matt

You can adapt this example
http://www.rondebruin.nl/copy6.htm

--
Regards Ron De Bruin
http://www.rondebruin.nl



"Matt" wrote in message ...
I am trying to write a macro that will save a copy of all visible sheets in
my workbook as single file webpages - .mht (one .mht file per sheet).

I have written the following which automatically publishes a single file
webpage for the current sheet but I have no idea how to generalise it to work
on all visible sheets. Can anyone Help?

Sub SaveSFWP()

Application.ScreenUpdating = False
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text & "
Departure.mht", "Sheet1", "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
ChDir "C:\Documents and Settings\MatthewA\Desktop"
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Save a single file webpage of each visible sheet in a workbook

Hi Matt

Add a sh.select line to the code
It only use the activesheet now

If sh.Visible = True Then
sh.select

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Matt" wrote in message ...
Thanks Ron,

I have used your example and changed my marco to the following:

Sub SaveMHTv2()

Application.ScreenUpdating = False
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = True Then
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text
& ActiveSheet.Name & ".mht", ActiveSheet.Name, "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
End If
Next sh

ChDir "C:\Documents and Settings\MatthewA\Desktop"

Application.ScreenUpdating = True

End Sub

Unfortunately it is still only saving the first sheet of the workbook as a
single file webpage. I think it is due to the With statement that I am using.

Any idea why it is not running on all the visible sheets?

Thanks

Matt



"Ron de Bruin" wrote:

Hi Matt

You can adapt this example
http://www.rondebruin.nl/copy6.htm

--
Regards Ron De Bruin
http://www.rondebruin.nl



"Matt" wrote in message ...
I am trying to write a macro that will save a copy of all visible sheets in
my workbook as single file webpages - .mht (one .mht file per sheet).

I have written the following which automatically publishes a single file
webpage for the current sheet but I have no idea how to generalise it to work
on all visible sheets. Can anyone Help?

Sub SaveSFWP()

Application.ScreenUpdating = False
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text & "
Departure.mht", "Sheet1", "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
ChDir "C:\Documents and Settings\MatthewA\Desktop"
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Save a single file webpage of each visible sheet in a workbook

Cheers Ron, That has done the trick!

"Ron de Bruin" wrote:

Hi Matt

Add a sh.select line to the code
It only use the activesheet now

If sh.Visible = True Then
sh.select

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Matt" wrote in message ...
Thanks Ron,

I have used your example and changed my marco to the following:

Sub SaveMHTv2()

Application.ScreenUpdating = False
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = True Then
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text
& ActiveSheet.Name & ".mht", ActiveSheet.Name, "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
End If
Next sh

ChDir "C:\Documents and Settings\MatthewA\Desktop"

Application.ScreenUpdating = True

End Sub

Unfortunately it is still only saving the first sheet of the workbook as a
single file webpage. I think it is due to the With statement that I am using.

Any idea why it is not running on all the visible sheets?

Thanks

Matt



"Ron de Bruin" wrote:

Hi Matt

You can adapt this example
http://www.rondebruin.nl/copy6.htm

--
Regards Ron De Bruin
http://www.rondebruin.nl



"Matt" wrote in message ...
I am trying to write a macro that will save a copy of all visible sheets in
my workbook as single file webpages - .mht (one .mht file per sheet).

I have written the following which automatically publishes a single file
webpage for the current sheet but I have no idea how to generalise it to work
on all visible sheets. Can anyone Help?

Sub SaveSFWP()

Application.ScreenUpdating = False
With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Documents and Settings\MatthewA\Desktop\" & Range("a1").Text & "
Departure.mht", "Sheet1", "", _
xlHtmlStatic, "Book1_30587", "")
.Publish (True)
.AutoRepublish = False
End With
ChDir "C:\Documents and Settings\MatthewA\Desktop"
End Sub






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
Save autofiltered visible sheet to csv file? [email protected] Excel Discussion (Misc queries) 3 February 26th 07 10:38 PM
how do i save a single sheet from my workbook? eyesonly1965[_14_] Excel Programming 5 May 14th 06 08:30 PM
Can you save a single sheet directly to a new file defensiveone Excel Worksheet Functions 2 May 13th 05 08:10 PM
Save a single sheet from a workbook JAMES T. Excel Discussion (Misc queries) 2 January 25th 05 02:16 PM
print and save a single sheet from a workbook using a commandbutt. bibio_ Excel Programming 1 November 13th 04 12:53 PM


All times are GMT +1. The time now is 03:43 PM.

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

About Us

"It's about Microsoft Excel"