+ Reply to Thread
Results 1 to 4 of 4

VBA to prevent saving

  1. #1
    Registered User
    Join Date
    02-08-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    VBA to prevent saving

    Hi,

    I have the following code, which works fine to prevent people saving my file when I'm using excel 2007 (at work), however when I use it on my home computer, on excel 2013, the message pops up but I can still save the file, can anyone tell me why and how to fix it:

    "Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox ("The 'Save As' function has been disabled")
    Cancel = True

    End Sub"

    Thanks

    Tom

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to prevent saving

    Hi Tcowap,

    This might do what you want, but you've got to disable events to get the code in and re-enable events to make it work

    Option Explicit

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    02-08-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA to prevent saving

    Thanks a lot for this

    Do you have any idea why my code stopped working when it moved from excel 2007 to excel 2013?

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to prevent saving

    You're welcome! I have no idea, I'm on Excel 2010

+ 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] Private sub to prevent saving
    By EdwardStephenson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2015, 05:19 AM
  2. [SOLVED] Password to Prevent Saving
    By prjt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-28-2014, 02:43 PM
  3. prevent a sheet from saving
    By CappyLarou in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2011, 09:08 AM
  4. Prevent saving
    By LydiasDad in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-11-2011, 02:40 PM
  5. Prevent a Saving Error
    By JamesT1 in forum Excel General
    Replies: 7
    Last Post: 08-26-2008, 01:55 PM
  6. Prevent users from saving
    By hr3 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-20-2006, 10:36 PM
  7. [SOLVED] prevent saving a worksheet
    By looking4help in forum Excel General
    Replies: 2
    Last Post: 03-17-2005, 07:06 PM

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