Workbook_beforeClose not working in add-in?

muffins

Board Regular
Joined
Jun 18, 2002
Messages
86
I've the following code in my add-in. Strangely the code in the Workbook_Open event executes as expected, but not the Workbook_beforeClose event. May I know the reason?

thank you very much.

*********************************************

Private Sub Workbook_Open()
msgbox "hi!"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
msgbox "bye!"
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Muffins,

Have a look here for an Auto_Close option:

http://groups.google.com/groups?hl=...TF-8&selm=3abf302d%241%40news.datev.de&rnum=1

Or here for an Application Level Events option:

http://groups.google.com/groups?hl=...selm=%23JJ6AvZ9AHA.1940%40tkmsftngp07&rnum=10

HTH

EDIT : Added second link.
_________________<font color="blue"> «««<font color="red">¤<font color="blue"><font size=+1>Richie</font><font color="red">¤<font color="blue"> »»»</font>

caffeine_sample.gif
</gif>
This message was edited by Richie(UK) on 2002-11-05 05:29
 
Upvote 0
Auto_close is an application level event, what if I want to place my code at the WorkBook level? eg my add-in will create a menu when workbook opens and delete the menu when the workbook is closed.
This message was edited by muffins on 2002-11-06 00:53
 
Upvote 0
Auto_Close in not an application level event. It will work just like Workbook_BeforeClose if placed in a general module in your Add-In.
 
Upvote 0
thanks but i've tried and it just didnt delete my menu upon workbook closing; my code in Auto_Close did not execute.. =(
 
Upvote 0
i didn't close the add-in. how shld i do it programatically?

thank you for your patience..
 
Upvote 0
I thought so.

Workbooks("MyAddin.xla).Close

You may then find that your original Workbook_BeforeClose event procedure will work.
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,769
Members
448,991
Latest member
Hanakoro

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