Reputation: 13
I need this macro to run when the .xlsm workbook is opened. It only runs if I manually run the macro, it does not start when the workbook is opened. FYI, I've checked/verified macro security (this is not signed yet).
Any ideas what I'm doing wrong?
Sub Workbook_Open()
MsgBox "Hello World!"
End Sub
Upvotes: 1
Views: 2607
Reputation: 21619
Your code needs to be located in the ThisWorkbook
module.
ThisWorkbook
. (If you have multiple workbooks open, make sure you choose the ThisWorkbook
under the correct project.) General
.This will bring you to a new (or existing) Workbook_Open
procedure:
Private Sub Workbook_Open()
End Sub
That's where your code should be placed.
Note that clicking the other drop-down at the top-right of the Code Editor pane, will list the other Workbook-level procedures you can add.
Upvotes: 1