+ Reply to Thread
Results 1 to 5 of 5

Creating Message Box after Saving

Hybrid View

smh242 Creating Message Box after... 11-17-2010, 11:55 AM
StephenR Re: Creating Message Box... 11-17-2010, 12:00 PM
ReportMaker Re: Creating Message Box... 11-17-2010, 12:06 PM
smh242 Re: Creating Message Box... 11-18-2010, 03:15 PM
royUK Re: Creating Message Box... 11-19-2010, 02:24 AM
  1. #1
    Registered User
    Join Date
    09-30-2010
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    9

    Creating Message Box after Saving

    I just need a message box to appear after someone saves the Excel document. The message box will only have text and probably an "OK" button for the user to press. The box itself is completely independent from the "save", meaning that once the user pressed "save", the document is saved regardless if the user presses "OK" in the message box.

    So it's a pretty simple message box but when I looked on forums, the message boxes introduced were a little too complex for my simple request.

    Another item, can you inform me what I need to change to make the message box appear if someone closes the Excel spreadsheet? So rather than pressing Save, what if they close the spreadsheet. So please help with these two requests.

    Thanks so much.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Creating Message Box after Saving

    If I understand correctly, put this in the ThisWorkbook module (see VBE Project window):
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
    x
    
    End Sub
    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    x
    
    End Sub
    and this in a normal module
    Sub x()
    
    MsgBox "Text here", vbOKOnly
    
    End Sub
    But what is the point of this?
    Last edited by StephenR; 11-17-2010 at 12:03 PM.

  3. #3
    Registered User
    Join Date
    08-12-2010
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Creating Message Box after Saving

    Quote Originally Posted by smh242 View Post
    I just need a message box to appear after someone saves the Excel document. The message box will only have text and probably an "OK" button for the user to press. The box itself is completely independent from the "save", meaning that once the user pressed "save", the document is saved regardless if the user presses "OK" in the message box.

    So it's a pretty simple message box but when I looked on forums, the message boxes introduced were a little too complex for my simple request.

    Another item, can you inform me what I need to change to make the message box appear if someone closes the Excel spreadsheet? So rather than pressing Save, what if they close the spreadsheet. So please help with these two requests.

    Thanks so much.

    Hello

    I'll assume you've never used VBA in your life. Open up VBA (press ALT+F11 from Excel). In the Project Explorer double click "ThisWorkbook". If you can't see this make sure the Project Explorer is visible by going to View > Project Explorer. Then maximize the folder "Microsoft Excel Objects". "ThisWorkbook" should be there.

    A blank page will open. Near the top there should be two drop down boxes. The first should say "(General)". Change this to "Workbook" then select "BeforeSave". This event is fired when the user saves the document.

    In the sub that appears add your message box. E.g.:


    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        MsgBox "Your message.", vbOKOnly, "Your title"
    End Sub

    For when the user closes the workbook. Do the same but this time choose "BeforeClose" and stick your code in that new sub. E.g.:


    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        MsgBox "Your message.", vbOKOnly, "Your title"
    End Sub



    EDIT: Sorry, StephenR beat me to it.
    Last edited by ReportMaker; 11-17-2010 at 12:07 PM. Reason: Slow

  4. #4
    Registered User
    Join Date
    09-30-2010
    Location
    Rochester
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Creating Message Box after Saving

    Thanks! It worked. The purpose is that this spreadsheet is going out to 800+ people to fill out information. After they save, I want them to read a message to remind them the importance of certain data. I don't want to put additional formatting/calculation into the spreadsheet because it'll just slow the thing down. So I just want a simple message box.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Creating Message Box after Saving

    You will probably be better off in this situation to use Conditional Formatting and/or Data Validation to ensure correct input. If a user doesn't enable macros then your warning messages won't appear.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1