+ Reply to Thread
Results 1 to 8 of 8

Disable SaveAs option allow save

Hybrid View

  1. #1
    Registered User
    Join Date
    06-03-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    27

    Disable SaveAs option allow save

    I have use this code to prevent user from use saveas option.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
     Cancel = True
      MsgBox "_____________________________"
     End Sub
    This code also disable save & saveAs option. But i dont want disable save option.

    I have inserted this macro beforeclose workbook. Where i mention save workbook.

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim answer As String
        Dim question As String
            question = "would you like to give your suggestion"
        answer = MsgBox(question, vbYesNo)
         
        If answer = vbYes Then
            MsgBox "Please mail me at ___________________ ", , ""
            Cancel = True
            Exit Sub
        Else
            ThisWorkbook.Save
        End If
    End Sub
    Request you to guide me to solve above problem.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Disable SaveAs option allow save

    This will prevent the BeforeSave event procedure from triggering.

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim answer As String
        Dim question As String
            question = "would you like to give your suggestion"
        answer = MsgBox(question, vbYesNo)
         
        If answer = vbYes Then
            MsgBox "Please mail me at ___________________ ", , ""
            Cancel = True
            Exit Sub
        Else
            Application.EnableEvents = False
            ThisWorkbook.Save
            Application.EnableEvents = True
        End If
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    06-03-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    27

    Re: Disable SaveAs option allow save

    Thanks for quick Response. #AlphaFrog
    I have posted one more query but still waiting for reply from member.
    i will my pleasure if you solve that also. As you are Forum Guru Aka master in excel working.

  4. #4
    Registered User
    Join Date
    07-21-2015
    Location
    Earth
    MS-Off Ver
    2013
    Posts
    28

    Re: Disable SaveAs option allow save

    Here you are!
    This code will Disable Save As, but allow you to Save the file!

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    'This will disable SaveAs function, but allow you to save the file!
    'Author: gaixixon@gmail.com
        Cancel = True
        If SaveAsUI Then
        f = MsgBox("SaveAs function is disabled!", vbCritical)
        Exit Sub
        End If
        Cancel = False
        Me.Save
    End Sub
    Attached Files Attached Files
    Last edited by gaixixon; 08-08-2016 at 10:27 PM.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Disable SaveAs option allow save

    Try this
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        Cancel = SaveAsUI
        If SaveAsUI Then MsgBox "SaveAs disabled"
    End Sub
    Last edited by mikerickson; 08-08-2016 at 11:16 PM.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    07-21-2015
    Location
    Earth
    MS-Off Ver
    2013
    Posts
    28

    Re: Disable SaveAs option allow save

    Quote Originally Posted by mikerickson View Post
    Try this
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        Cancel = SaveAsUI
        If SaveAsUI Then MsgBox "SaveAs disabled"
    End Sub
    Can't be shorter and better code!

  7. #7
    Registered User
    Join Date
    06-03-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    27

    Re: Disable SaveAs option allow save

    Thanks So much.

  8. #8
    Registered User
    Join Date
    07-21-2015
    Location
    Earth
    MS-Off Ver
    2013
    Posts
    28

    Re: Disable SaveAs option allow save

    .............................................. typo error..
    Last edited by gaixixon; 08-11-2016 at 04:44 AM. Reason: typo..

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Code request to disable save as option
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2015, 01:36 AM
  2. Disable Save/SaveAs in 2007
    By ultimastryder in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2013, 10:26 AM
  3. Replies: 1
    Last Post: 06-16-2013, 12:35 AM
  4. Disable/Enable Save,SaveAs & Sendto in File Menu based on condition
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2011, 04:43 AM
  5. disable save and saveas but have submit button to save file as work
    By briant97 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2010, 12:32 PM
  6. [SOLVED] Disable option save when close excel
    By Rui Alvares in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2006, 10:00 PM
  7. disable save as.. option
    By onidallap in forum Excel General
    Replies: 0
    Last Post: 04-20-2005, 09:23 AM

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