I don't think you can run a messagebox after the workbook containing the code is closed.
Is it possible to have a message box appear after a WorkBook is closed. I have code that automatically closes a work book after a certain amount of inactivity and would like a message box to inform the user what happened.
It doesn't work that wayVB:Sub CloseBook() Call StopCycle Unload CloseTimer Unload EnterPassword ThisWorkbook.Saved = True ThisWorkbook.Close MsgBox "Your Excel Workbook Closed Due to Inactivity" End Sub![]()
I don't think you can run a messagebox after the workbook containing the code is closed.
Hope that Helps
Roy
For free Excel tools & articles visit my web site
If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need
About me.
Before Close yes, after close no as You will not longer be running Excel so the VBIDE can not process this information.
Try in the workbook module
VB:Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "Excel will now close" Exit Sub End Sub Private Sub Workbook_Open() End Sub
I really want to pop up a message after the book has closed. Excel is still open after the book is closed.
I already have a form that pops up after 2 minutes of inactivity which has a 25 second counter, a button the user can click to stop the automatic closing and a button they can press to close the book immediately if they want. I just want a message to pop up after the book closes incase they were away from the desk and are wondering what happened to the file.
The only way to do this would be if the code was outside the workbook, perhaps in an addin
Hope that Helps
Roy
For free Excel tools & articles visit my web site
If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need
About me.
As Jack has said You can not do this not matter how You asks the question the VBIDE is closed. Excel is not producing the message box the VBIDE is, therefore unless an Excel WorkBook is open the VBIDE can not process the VBA scripts, thus no can do that is just the way it works. This answers Your question.
Jack is not having a go at You or the question, just explaining the way these things work, this will assist You if You need or want a fix ie
Now You understand this can not be done the way You would like Jack can offer an way out, use the persanal.xls and have the close event call the rersonal.xls scripts top pop up Your message and the personal.xls will still be in session, thus fixing Your problem and giving You want You want; and message after closing that WorkBook
Hope this helps You get where You are looking, let Jack know if You need more help?
jiuk
BTW You must remember that to run VBA codes in fact You are running two separate applications that is Excel and the VBE (VBIDE) there for if we say what came first it would be the chicken, ie Excel
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks