More than one event in workbook object?

vincent2722

New Member
Joined
Jul 8, 2009
Messages
4
Hey guys,

This may be a dumb question because I've been looking for an answer all over the internet and can't find the problem mentioned anywhere. I'm relatively new to Excel VBA though, and I'm trying to create two events for a single workbook. Is this possible?

I have one workbook open event and one workbook save event. I can insert both of them into the code window, but only the worokbook open event (which is listed first) fires.

If doing this is not possible, does anyone have any other suggestions? Both events are fairly complex, in my opinion, and involve several actions. If any suggestions require seeing the actual code I can put it up as well.

Thanks in advance!!

Vincent
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi Vincent,
I have one workbook open event and one workbook save event.... ....but only the worokbook open event (which is listed first) fires
The order of the event handlers in the module does not matter. I think the problem is that there is no native Workbook_Save() event handler; the event handler you probably want to use is Workbook_BeforeSave(), ie:
Code:
Option Explicit
 
Private Sub Workbook_Open()
    '''
End Sub
 
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    '''
End Sub

If you are already correctly using the Workbook_BeforeSave() event handler then, if the Workbook's BeforeSave event is not raised when the workbook is saved then that would suggest that Application.EnableEvents has been set to False.

If you are still having problems then please post the code and other relevant information.

Hope that helps...
 
Upvote 0
Colin,

Thank you! I'm a bit embarrassed, but you just cured a big headache of mine! Turned out you were right and there was an orphaned "Application.EnableEvents = False" hiding in my code.

Again, thank you!


Vincent
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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