简体   繁体   English

如何使用VBA禁用Excel中的保存和受保护的工作表提示

[英]How to disable save and protected sheet prompt in excel using VBA

I have an excel sheet which is protected, since the sheet is protected I don't want the user to save it, and I don't want the save the sheet prompt to appear when someone closes the workbook. 我有一个受保护的Excel工作表,因为工作表受到保护我不希望用户保存它,并且我不希望当有人关闭工作簿时save the sheet prompt Till now I have been using this: 直到现在我一直在使用这个:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True
    Application.DisplayAlerts = False
End Sub

Using this code, save feature is disabled but the prompt is still appearing 使用此代码,已禁用保存功能,但仍显示提示

Similar problem: 类似的问题:
Since the workbook is protected whenever someone tries to change the cell content it displays an alert, I want to disable that prompt message as well. 由于每当有人试图更改单元格内容时工作簿都会受到保护,它会显示警报,我也想禁用该提示消息。 Can someone help me to fix this 有人可以帮我解决这个问题

L42 has already answered part of your question. L42已经回答了部分问题。

I want to disable that prompt message as well. 我也想禁用该提示信息。

Do this. 做这个。 While protecting the sheet, unckeck the option Select Locked Cells . 保护工作表时,请取消Select Locked Cells ”选项。 Now that will take care of the keyboard input while the sheet is locked and protected. 现在,这将在工作表被锁定和保护时处理键盘输入。

在此输入图像描述

As for mouse inputs ie the prompt showing up when you double click on the cell, use this :) 至于鼠标输入,即双击单元格时出现提示,请使用此:)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM