Excel macro does not run on opening

CC10
CC10 used Ask the Experts™
on
I have seen many answers on this but unfortunately I cannot find the fault.

I automatically open a workbook when Excel opens, using  Option, Advanced, General, at startup open all file in etc...

Then in the ThisWorkbook Object I have inserted:

Private Sub Auto_Open()

Application.Run ("RunMacros")

End Sub

The "RunMacros" macro is inserted in Module1

If I browse through using F8, the Auto_Open macro works but it does not work automatically on opening.


Thanks,
CC
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
What level is your Macro Security currently set at?

Author

Commented:
it is on

Enable all macros and Trust access to the VBA Project object model

Author

Commented:
Sorry I have checked again and it seems that the macro "Run Macros" is not working properly. I will revert.
byundtMechanical Engineer
Most Valuable Expert 2013
Top Expert 2013

Commented:
FWIW, an Auto_Open macro normally goes in a regular module sheet rather than in ThisWorkbook code pane.

If you want to keep an equivalent sub in ThisWorkbook, the preferred approach is to use Workbook_Open:
Private Sub Workbook_Open()
Application.Run ("RunMacros")
End Sub

Open in new window

Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013
Commented:
My tests in Excel 2003 show that an Auto_Open sub will run when the workbook opens if it is stored in a regular module sheet, but not if it is stored in ThisWorkbook code pane.

Brad

Author

Commented:
Thanks. It now works. I awarded 50pts to the first expert because he answered first.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial