F8 runs macro but not Auto_Open

tmpollard

Board Regular
Joined
Jun 12, 2008
Messages
111
Hello,
Wondering if someone can help with this auto macro. Basically all I'm doing in this test sheet is changing the colors of some cells, Saving the sheet, then saving the sheet a .mht file, and closing excel.

I'm getting an error that says "Code execution has been interrupted", when I click debug it highlights this line as being a problem
"ActiveWorkbook.SaveAs Filename:="C:\HTM\APP\CO\Test1.mht", FileFormat:=xlWebArchive, CreateBackup:=False"

I have also noticed that if I run the code by holding down the F8 button it works fine with no errors. I have been working on this all day trying to figure it out. Any help would be appreciated. Thanks


Code:
Sub auto_open()
'
' auto_open Macro
    Range("A1:Q29").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    Range("A1").Select
    
    Application.DisplayAlerts = False
    
    ActiveWorkbook.SaveAs "C:\HTM\APP\CO\Test1.xlsm"
    
    ActiveWorkbook.SaveAs Filename:="C:\HTM\APP\CO\Test1.mht", FileFormat:=xlWebArchive, CreateBackup:=False
    
    Application.DisplayAlerts = True
    
    Application.Quit

[\Code]
 
Last edited:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I believe that when you do the SaveAs you effectively close the .xlsm file and the macro stops. You could try the SaveCopyAs syntax and see if that will give you the new file without closing the original and it should avoid the alert message.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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