Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 6 of 6

Thread: Msgbox After Automatic Workbook Close

  1. #1
    Join Date
    7th March 2007
    Location
    Omaha, Ne, USA
    Posts
    37

    Msgbox After Automatic Workbook Close

    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.

    VB:
    Sub CloseBook() 
        Call StopCycle 
        Unload CloseTimer 
        Unload EnterPassword 
        ThisWorkbook.Saved = True 
        ThisWorkbook.Close 
        MsgBox "Your Excel Workbook Closed Due to Inactivity" 
    End Sub 
    
    
    It doesn't work that way

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    17,467

    Re: Msgbox After Automatic Workbook Close

    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

    RoyUK's Web Site

    royUK's Database Form

    About me.

  3. #3
    Join Date
    26th January 2003
    Location
    UK
    Posts
    4,682

    Re: Msgbox After Automatic Workbook Close

    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 
    
    

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    7th March 2007
    Location
    Omaha, Ne, USA
    Posts
    37

    Re: Msgbox After Automatic Workbook Close

    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.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    17,467

    Re: Msgbox After Automatic Workbook Close

    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

    RoyUK's Web Site

    royUK's Database Form

    About me.

  6. #6
    Join Date
    26th January 2003
    Location
    UK
    Posts
    4,682

    Re: Msgbox After Automatic Workbook Close

    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

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Close Msgbox After X Seconds
    By rburden in forum EXCEL HELP
    Replies: 3
    Last Post: January 5th, 2008, 06:25
  2. Remove close "X" button on msgbox?
    By Pavel in forum EXCEL HELP
    Replies: 2
    Last Post: May 4th, 2005, 10:33
  3. Automatic file close
    By planetz007 in forum EXCEL HELP
    Replies: 3
    Last Post: April 27th, 2005, 23:54
  4. VBA to close Excel Window on close last workbook
    By Dovrox in forum EXCEL HELP
    Replies: 2
    Last Post: September 22nd, 2004, 18:06
  5. Automatic save on workbook close
    By simpsonc2 in forum EXCEL HELP
    Replies: 7
    Last Post: August 11th, 2004, 19:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno