禁用Excel保存选项,但允许宏保存 [英] Disable Excel save option but allow macro save
本文介绍了禁用Excel保存选项,但允许宏保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个excel文件,我想要禁用保存和另存为...选项。
I'm creating an excel file and I want to disable the 'save' and 'save as...' option.
我发现了很多解决方案在互联网上,像VBA中的一样:
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
它阻止用户保存更改,但我无法保存我的更改,这是问题,因为我需要在VBA代码中进行更多更改。
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... ?
感谢您的未来答案。
推荐答案
使用全局变量覆盖Save disable:
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
这篇关于禁用Excel保存选项,但允许宏保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文