如何禁用Excel中的“保存”选项,但保留“另存为”选项。

huangapple go评论225阅读模式
英文:

How to disable 'save' option in Excel but 'save as'

问题

Private Sub Workbook_BeforeSave(ByVal SaveUI As Boolean, Cancel As Boolean)
    MsgBox "无法保存此工作簿!"
    Cancel = True
End Sub

当我们使用这个命令来禁止在Excel工作表中保存时,隐藏的工作表会从用户视图中显示出来。我该如何解决这个问题?

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

When we use this command to disable saving in Excel sheets that we have hidden, they are displayed from the user's view. How can I solve this problem?

答案1

得分: 1

禁用保存功能,但允许另存为,请尝试以下方法...

Private Sub Workbook_BeforeSave(ByVal SaveUI As Boolean, Cancel As Boolean)
    If SaveUI = False Then
        MsgBox "无法保存此工作簿!"
        Cancel = True
    End If
End Sub
英文:

To disable Save, but allow SaveAs, try the following...

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

huangapple
  • 本文由 发表于 2023年5月29日 02:52:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76353114.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定