Macro won't continue after it runs another macro that saves as

Joe Patrick

New Member
Joined
May 15, 2011
Messages
44
Hi!

I have mutiple spreadsheets, each with its own Auto_Open macro that imports text, formats, saves, saves as webpage, close active workbook:

Sub Auto_Open()
'import text
'format
ActiveWorkbook.Save
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="U:\TPCentral_Too\ADA_Requests\ADA_Requests.htm" _
, FileFormat:=xlHtml, ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub

I'm trying to have one spreadsheet with an Auto_Open macro that does this:

Sub Auto_Open() 'update all
Workbooks.Open(Filename:="U:\TPCentral_Too\ADA_Requests\ADA_Requests2.xls"). _
RunAutoMacros Which:=xlAutoOpen
Workbooks.Open(Filename:="U:\TPCentral_Too\ADA_Requests\ADA_Requests1.xls"). _
RunAutoMacros Which:=xlAutoOpen
End Sub

The problem is that the macro stops cold after the first AutoOpen. The window with the macro is still open, so it's not that.

Is there a solution for this?

Thank you in advance for any help!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
With some help from Bertie I figured this one out. Thanx Bertie!!

-Changed Auto_Open to ThisWorkbook.AutoUpdate
-Removed this line from AutoUpdate: ActiveWorkbook.Close

Sub UpdateTPC2()
Set objExcel = CreateObject("Excel.Application")
Set wbExcel = objExcel.Workbooks.Open("U:\TPCentral_Too\ADA_Requests\ADA_Requests.xls")
With objExcel
.Application.Run ("ThisWorkbook.AutoUpdate")
End With
wbExcel.Close SaveChanges:=False
Set objExcel = CreateObject("Excel.Application")
Set wbExcel = objExcel.Workbooks.Open("U:\TPCentral_Too\ADA_Requests\ADA_Requests2.xls")
With objExcel
.Application.Run ("ThisWorkbook.AutoUpdate")
End With
wbExcel.Close SaveChanges:=False
MsgBox "TPC2 has been updated"
ActiveWorkbook.Close
End Sub
 
Upvote 0
correction:

Sub UpdateTPC2()
Set objExcel = CreateObject("Excel.Application")
Set wbExcel = objExcel.Workbooks.Open("U:\TPCentral_Too\ADA_Requests\ADA_Requests.xls")
With objExcel
.Application.Run ("ThisWorkbook.AutoUpdate")
End With
wbExcel.Close SaveChanges:=False
Set objExcel = CreateObject("Excel.Application")
Set wbExcel = objExcel.Workbooks.Open("U:\TPCentral_Too\ADA_Requests\ADA_Requests2.xls")
With objExcel
.Application.Run ("ThisWorkbook.AutoUpdate")
End With
wbExcel.Close SaveChanges:=False
Set wbExcel = Nothing
Set objExcel = Nothing
MsgBox "TPC2 has been updated"
ActiveWorkbook.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,612
Messages
6,179,890
Members
452,948
Latest member
Dupuhini

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