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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Richie(UK)

MrExcel MVP
Joined
May 17, 2002
Messages
3,329
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
 

muffins

Board Regular
Joined
Jun 18, 2002
Messages
86
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
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

muffins

Board Regular
Joined
Jun 18, 2002
Messages
86

ADVERTISEMENT

thanks but i've tried and it just didnt delete my menu upon workbook closing; my code in Auto_Close did not execute.. =(
 

muffins

Board Regular
Joined
Jun 18, 2002
Messages
86

ADVERTISEMENT

i didn't close the add-in. how shld i do it programatically?

thank you for your patience..
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
I thought so.

Workbooks("MyAddin.xla).Close

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

muffins

Board Regular
Joined
Jun 18, 2002
Messages
86
i see... but where do i place this piece of code?

thank you very much.
 

Forum statistics

Threads
1,143,640
Messages
5,719,984
Members
422,256
Latest member
downeybm

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
Top