save as a web-part

silverskye787

Board Regular
Joined
Jun 18, 2007
Messages
109
I know how to save a excel file manually but how can i do it automatically?

I have created a button on sheet3 and i want it to be click and it will save
automatically the whole of (sheet1 & sheet2) into two web parts into the current folder.

how do i do it?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
what do u mean two web parts ????

Below code save the entire workbook as htm

Code:
Sub Save()




Sheets("Sheet3").Select
Range("z6000").Select
    ActiveCell.FormulaR1C1 = _
        "=LEFT(CELL(""Filename""),FIND(""["",CELL(""Filename""),1)-1)"
    
    d = Range("z6000")
    
 

    ThisWorkbook.SaveAs Filename:= _
        d & "Book4.htm", FileFormat:=xlHtml _
        , ReadOnlyRecommended:=False, CreateBackup:=False
        'ThisWorkbook.Save , FileFormat:=xlHtml _
        , ReadOnlyRecommended:=False, CreateBackup:=False
        
        
    Sheets("Sheet3").Select
    Range("z6000").Select
    Selection.ClearContents
    Sheets("Sheet1").Select
    Range("A1").Select
End Sub
 
Upvote 0
Do u mean saving Sheet1 as one Web Page & Sheet2 as another webpage ?

Below is the code

Code:
Sub Save()

'Find the Workbook directory

Sheets("Sheet3").Select
Range("z6000").Select
    ActiveCell.FormulaR1C1 = _
        "=LEFT(CELL(""Filename""),FIND(""["",CELL(""Filename""),1)-1)"
    
    d = Range("z6000")
    
'Save sheet1
 Sheets("Sheet1").Select
  With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
        d & "Sheet1.htm", "Sheet1" _
        , "", xlHtmlStatic, "", "")
        .Publish (True)
        .AutoRepublish = False
    End With
    
   
 'Save sheet2
 Sheets("Sheet2").Select
  With ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
        d & "Sheet2.htm", "Sheet2" _
        , "", xlHtmlStatic, "", "")
        .Publish (True)
        .AutoRepublish = False
    End With

'Delete content written in cell Z6000

    Sheets("Sheet3").Select
    Range("z6000").Select
    Selection.ClearContents
    Sheets("Sheet1").Select
    Range("A1").Select
End Sub

Note the Worksheet Name is Sheet1 , Sheet2 & Sheet3 ... pls modify accordingly if ur worksheet name is different..... it will save to the directory where your excel worksheet is.
 
Upvote 0
thanks alot...

how about specifiying a specific cell instead of the sheets

example:

A2 has the name exactly the same as one of the sheet.. then it will convert that sheet to HTML.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,978
Latest member
rrauni

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