Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Disable save but allow Macro to save

  1. #1
    New Member
    Join Date
    Aug 2008
    Location
    Edinburgh, UK
    Posts
    25
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Disable save but allow Macro to save

    I am using the code below to disable the save function very successafully. However, is there a work around to allow a macro to save?
    ----------------------------------------------------------------------
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    'this disables the save function on the XLS

    MsgBox "****Save is Disabled****"
    ' Following line will prevent all saving
    Cancel = True
    ' Following line will prevent the Save As Dialog box from showing
    If SaveAsUI Then SaveAsUI = False
    End Sub

  2. #2
    MrExcel MVP VoG's Avatar
    Join Date
    Jun 2002
    Location
    127.0.0.1
    Posts
    63,651
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)

    Default Re: Disable save but allow Macro to save

    In your macro that does the saving

    Code:
    Application.EnableEvents = False
    '
    'code to save
    '
    Application.EnableEvents = True
    HTH, Peter
    Please test any code on a copy of your workbook.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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