Disable Excel save option but allow macro save

后端 未结 2 1480
[愿得一人]
[愿得一人] 2020-12-22 09:32

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:



        
相关标签:
2条回答
  • 2020-12-22 09:44

    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
    
    0 讨论(0)
  • 2020-12-22 09:58

    You can also save while in Design Mode in VBA.

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

    0 讨论(0)
提交回复
热议问题