Save script issue

Ormus

Board Regular
Joined
Nov 1, 2011
Messages
92
Having trouble with this script

Code:
Sub Save1()
Dim dag, uur, tussen, xlsline, webline
dag = CStr(Date)
tijd = CStr(Hour(Time))
If Hour(Time) < 10 Then tussen = "0" Else tussen = ""
xlsline = InputBox("Under what name should the product be saved?", "Save as", dag + "-test XXX.xls")
MsgBox (xlsline)
webline = InputBox("Under what name should the product be saved?", "Save as", dag + "-test XXX.mht")
MsgBox (webline)
    ChDir _
        "C:\Test1"
    Range("B2:H23").Select
    With ActiveWorkbook.PublishObjects.add(xlSourceRange, _
        webline _
        , "WWA", "$B$2:$H$23", xlHtmlStatic, "WWA1_16010", "")
        .Publish (True)
        .AutoRepublish = False
    End With
    
        
        
    ChDir _
        "C:\Test2"
    Range("B2:H23").Select
    With ActiveWorkbook.PublishObjects.add(xlSourceRange, _
        webline _
        , "WWA", "$B$2:$H$23", xlHtmlStatic, "WWA1_16010", "")
        .Publish (True)
        .AutoRepublish = False
    End With
       
     
    ChDir "C:\test3"
    ActiveWorkbook.SaveAs Filename:=xlsline, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
     
End Sub

What I want to do:

Save 2 copies as single page webpages to different folders, and a 3rd copy (in a different folder), in excel format.

The above script instead saves a web and excel version in test 3.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Something really odd with this script, it works the first time, but does not for the 2+ times (it places the files in test 3, instead of one each in test1, test2 and test3)

If I save as and right over the file, or make a new one, it again works for the first time but not for the 2+ time. Any thoughts?
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,167
Members
448,554
Latest member
Gleisner2

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