Automatically Run Workbook Event on Workbook Open

ilcaa

Well-known Member
Joined
May 25, 2005
Messages
751
Office Version
  1. 365
Platform
  1. Windows
I have this macro stored in my personal.xlsb folder and it is stored in "This Workbook".

Everytime a workbook is open a want to run a SUB() that checks the name of the workbook and does something depending on certain workbook names....

i am trying this small macro just to test it and It doesnt run automatically once a workbook opens.

Private Sub Workbook_Open()
If ActiveWorkbook.Name = "indeed" Then
msgBox (ActiveWorkbook.Name)
Else
MsgBox (ActiveWorkbook.Name)
End If
End Sub


what am i doing wrong to have this run automatically everytime a workbook is opened? thanks
 
thanks for posting the code. But for me, it did not produce the intended results.


I replaced my original macro with your code within "thisworkbook" in my personal.xlsb

i assume I don't need to tweak anything. But when I open different workbooks, nothing happens. Did you run it on your end and it worked???


thanks for the help.
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
still cant figure this out, can you please explain a little bit more about need is to trap the Application events not the Workbook events and your code, it doesnt seem to work as you suggested, thank you!!
 
Upvote 0
still cant figure this out, can you please explain a little bit more about need is to trap the Application events not the Workbook events and your code, it doesnt seem to work as you suggested, thank you!!

The application level events work on every workbook that is open inside the excel application session.

If you place the code I provided inside the Personal workbook module ie in the ThisWorkbook module of the Personal.xls then every time a new workbook is added or an existing workbook is opened you should get a message box displaying the name of the workbook.

I don't use Excel 2007 so I am not familiar with the new File format personal.xlsb but I don't think that would make any difference.
 
Upvote 0

Forum statistics

Threads
1,216,750
Messages
6,132,500
Members
449,730
Latest member
SeanHT

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