Link to home
Avatar of Bob3975
Bob3975Flag for United States of America

asked on

workbook_open() not working

In an existing workbook within This Workbook I added
------------
Private Sub Workbook_Open()
  Main
End Sub
-------------

It doesn't run.  So I changed it to Auto_Open and it runs except it only shows the Excel 2010 splashscreen rather than the workbook as the macro runs.  I'd much rather see the workbook as it runs rather than the splashscreen.

How can I get the results I'm looking for?
ASKER CERTIFIED SOLUTION
Avatar of Eoin Ryan
Eoin Ryan
Flag of Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Maybe a DoEvents before the Main macro.
Is there an Application.ScreenUpdating = false at the start of the Main macro? Turn this to true if you want to see changes.
Avatar of Bob3975

ASKER

EoDawg,
As written your solution will not work since Main is not in the new workbook but it was enough to get me thinking.  I rewrote it as shown below for a functional solution.
-------------------
Private Sub Auto_open()
Dim aWb As Workbook
Dim thisWb As String
thisWb = ActiveWorkbook.name

Set aWb = Workbooks.Add
ActiveWorkbook.Close False

Workbooks(thisWb).Activate

Main

End Sub
-----------------