0

I'm creating an excel file and I want to disable the 'save' and 'save as...' option.

I found a lot of solutions on the internet, like this one in VBA:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
     MsgBox "You can't save this workbook!"
     Cancel = True
End Sub

It prevents user from saving changes, but I can't save my changes and that's the problem because I need to do more changes in the VBA code.

Is there a way to save my macro changes ? Like an administrator mode etc... ?

Thank you for your future answers.

0m3r
  • 12,286
  • 15
  • 35
  • 71
Eastrall
  • 7,609
  • 1
  • 16
  • 30

2 Answers2

2

Use a global variable to override the Save disable:

    Dim override as Boolean

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
         if Not(override) then
           MsgBox "You can't save this workbook!"
           Cancel = True
         end if
    End Sub
    Sub SaveMyChanges()
       override = true
       ActiveWorkbook.Save
       override = false
    End Sub
AnalystCave.com
  • 4,884
  • 2
  • 22
  • 30
0

You can also save while in Design Mode in VBA.

Sorry for the necro, but this works also and is what I do.

Awill
  • 107
  • 7
  • 24