+ Reply to Thread
Results 1 to 3 of 3

Macro for Saving tabs in Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    08-26-2009
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    5

    Macro for Saving tabs in Excel

    I have a handful of Excel tabs in a large workbook, which I want to save as a web page using a macro.

    I am trying to do something along the lines of:

    With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
    "C:\Documents and Settings\Administrator\Desktop\M3.htm", "M3", "", _
    xlHtmlStatic, "Summary Display_381", "")
    .Publish (True)
    .AutoRepublish = False
    End With
    but how can do the above for half a dozen tabs?
    Last edited by peter11111; 09-14-2009 at 08:13 PM.

  2. #2
    Registered User
    Join Date
    08-20-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: Macro for Saving tabs in Excel

    The following will save each tab in the workbook as a HTML file:

    Sub SaveTabsTohtml()
    Dim ws As Worksheet
    
    ChDir "C:\test\" ' change as required to where you want to save the files
    
        For Each ws In Worksheets
            ws.Activate
            ActiveWorkbook.SaveAs Filename:=ws.Name & ".html", _
                FileFormat:=xlHtml, CreateBackup:=False
        Next ws
    
    End Sub
    Is this is what you are after?

  3. #3
    Forum Contributor
    Join Date
    04-18-2009
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2016
    Posts
    269

    Re: Macro for Saving tabs in Excel

    I have a handful of Excel tabs in a large workbook
    Assuming tabs mean worksheets, the solution could be something like:

    Application.ScreenUpdating = False
    Dim i As Integer
    
    For i = 1 To Sheets.Count
    Sheets(i).Activate
    
    With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
    "C:\Users\Karan\Desktop\" & Sheets(i).Name & ".htm", Sheets(i).Name, "", _
    xlHtmlStatic, "Summary Display_381", "")
    .Publish (True)
    .AutoRepublish = False
    End With
    Next
    
    Application.ScreenUpdating = True
    --Karan--
    Last edited by karan; 09-14-2009 at 08:30 AM. Reason: Correction

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1