保存时不显示密码

时间:2019-03-21 03:06:31

标签: excel vba

我有一个Excel工作簿/数据库,当用户尝试保存时,我已经用密码保护了。

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim Password As String
    Dim EnteredPassword As String
    Password = "100%Laphr0a1g"
    'EnteredPassword = InputBox("Enter password to save changes")
    'If EnteredPassword = Password Then
    EnteredPassword = InputBox("Enter password to save changes")
    If EnteredPassword <> Password Then
        Cancel = True
        MsgBox ("Password incorrect, file not saved")
    End If
End Sub

我的问题是我想在安静模式下将工作簿保存在另一个例程中,并且我不想输入密码。

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

ChDir PathVal
ActiveWorkbook.SaveAs Filename:= _
    FileNameVal _
    , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False, 
ConflictResolution:=xlLocalSessionChanges

Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True

跳过Private Sub Workbook_BeforeSave例程的代码是什么,或者不输入密码就保存的代码是什么?

0 个答案:

没有答案