Consulting

Results 1 to 4 of 4

Thread: "Save As" prompt

  1. #1

    "Save As" prompt

    Hi folks,

    is it possible for Excel to display a message box when the user tries to close the file, the message being: "do you want to save this workbook under a different name?" with the choices of "Yes" or 'No." If "No" Excel proceeds to close the file, if "yes" the process is aborted so that the user can save the file under a different name.

    Thanks for your help.

    KG

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this. Put the code in the ThisWorkbook code section.


    Option Explicit
     
     Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim Prompt          As String
     Dim Title           As String
     Dim ShowSaveAs      As VbMsgBoxResult
    Prompt = "Do you want to save this file with a new name?"
         Title = "Save As Prompt"
         ShowSaveAs = MsgBox(Prompt, vbYesNo, Title)
         If ShowSaveAs = vbYes Then
             Application.Dialogs(xlDialogSaveAs).Show
         End If
    End Sub

  3. #3
    it works great. Thanks.
    I'll mark as "SOLVED"

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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