+ Reply to Thread
Results 1 to 7 of 7

Need code for Message upon closing.

  1. #1
    Registered User
    Join Date
    04-10-2013
    Location
    yukon
    MS-Off Ver
    Excel 2010
    Posts
    5

    Need code for Message upon closing.

    I am totally new to code and need some help please. I have a workbook that staff input data but once completed I need to provide a reminder to save as a new name.
    Much appreciate any help, we are using excel 2010.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need code for Message upon closing.

    Put this code in the ThisWorkbook module

    Please Login or Register  to view this content.
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    04-10-2013
    Location
    yukon
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need code for Message upon closing.

    Thanks for this, however I am still able to close it without changing the name. I put this code in the Macro screen and selected 'this workbook' but to now success, am I doing something wrong?

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need code for Message upon closing.

    OK

    This in a code module

    Please Login or Register  to view this content.
    This in the ThisWorkbook module

    Please Login or Register  to view this content.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Need code for Message upon closing.

    Hi, ygeducation,

    what about using a template for the workbook to be filled?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  6. #6
    Registered User
    Join Date
    04-10-2013
    Location
    yukon
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need code for Message upon closing.

    Thanks everyone, got it working, much appreciate you assistance.

  7. #7
    Registered User
    Join Date
    04-10-2013
    Location
    yukon
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Need code for Message upon closing.

    Came up with another issue and hope someone can help. I get the warning message upon closing but I need to input a "Cancel' feature otherwise when they click OK, it actually saves over the document. I need it to force the user to use the "Save As" feature only. Here is the code I currently have:
    [COLOR="#FF0000"]Private Sub Workbook_Open()
    MsgBox "This is only an input workbook.", vbInformation + vbOKOnly
    End Sub

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    MsgBox "Did you remember to save your work", vbInformation + vbOKOnly
    End Sub

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox "Remember to save file as the JV number.", vbCritical + vbOKOnly
    End Sub

+ 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