首页 > 解决方案 > 需要密码才能在 excel 365 中共享/发送电子邮件

问题描述

我有一个宏,在用户保存之前需要密码。我希望在用户可以使用共享按钮发送电子邮件之前需要一个。

这是我保存密码宏的代码

Private Sub Workbook_Beforesend(ByVal SendmailUI As Boolean, Cancel As Boolean)
'This macro disables the "Save As" Feature in Excel

'This means that a user will not be able to save this
'workbook(file) under a different name or in a different location
'
'This MUST be placed in "ThisWorkbook" and NOT in a Module.
'


    Const strPassword = "PASSWORD" ' the password to unlock Save As
If InputBox("Enter the password to display the Save As dialog, or click Cancel") <> strPassword Then
    MsgBox "You can't save this workbook!" & vbNewLine _
    & "To save this work book use the 'Click to Submit' button" & vbNewLine _
    & "this will save for you!"
    Cancel = True
       
    End If
End Sub

标签: excelemailpasswords

解决方案


推荐阅读