我认为您描述的方法中的密码保护即使完全可行,也不必要地麻烦。
他要求我用密码保护 Excel 电子表格,这样一个密码就不会解锁人们可以从网站下载的所有副本。
我无法想象仅使用 Excel 怎么可能做到这一点。也许加载项可以做到这一点,但在文件级别,我不认为它可以做到,至少不容易。
我永远无法确定谁在使用电子表格。
听起来这是非常重要的一点。您没有将密码用作安全措施,仅用作确定谁在使用文件的把关方法。这可以通过其他方式自动化,其中最简单的方式是使用某些Environment
变量,例如:
MsgBox Environ("username")
将显示一个带有当前用户名的消息框。
您可以分配Environ("username")
给一个字符串变量,然后您可以例如自动化 Outlook 向您发送一封“John Doe 已打开文件”的电子邮件,或类似的内容。如果您想避免每次都收到一封电子邮件,您可以在 Excel 文件中使用命名范围变量进行一些调整,以便宏只会发送一次电子邮件,等等。
或者,您可以将 log/txt 文件写入共享网络位置(当然,假设用户已连接到网络)而不是发送电子邮件。
更新
这是我从网络上获取的一些示例代码,它将发送来自用户的电子邮件。您将不得不修改这些sendTo
行以使用您的电子邮件地址作为收件人等。
把它放在工作簿的代码模块中,它应该在他们打开这个文件时给你发送电子邮件:
Option Explicit
Private Sub Workbook_Open()
' This example uses late-binding instead of requiring an add'l reference to the
' MS Outlook 14.0 Object Library.
Dim oApp As Object 'Outlook.Application 'Object
Dim ns As Object 'Namespace
Dim fldr As Object 'MAPIFolder
Dim mItem As Object 'Outlook.MailItem
Dim sendTo As Object 'Outlook.Recipient
Dim bOutlookFound As Boolean
On Error Resume Next
Set oApp = GetObject(, "Outlook.Application")
bOutlookFound = Err.Number = 0
On Error GoTo 0
If Not bOutlookFound Then Set oApp = CreateObject("Outlook.Application") 'New Outlook.Application
'# Set the namespace and folder so you can add recipients
Set ns = oApp.GetNamespace("MAPI")
Set fldr = ns.GetDefaultFolder(6) 'olFolderInbox
'# create an outlook MailItem:
Set mItem = oApp.CreateItem(0) 'olMailItem
'# assign a recipient
Set sendTo = mItem.Recipients.Add("YourName@Company.Com")
sendTo.Type = 1 'To olTo
'# assign another recipient
Set sendTo = mItem.Recipients.Add("YourManager@Company.Com")
sendTo.Type = 1
'# Validate the recipients (not necessary if you qualify valid email addresses:
For Each sendTo In mItem.Recipients
sendTo.Resolve
Next
mItem.Subject = "A user has opened the Excel file"
mItem.Body = "This is an automated message to inform you that " & _
Environ("username") & " has downloaded and is using the file."
mItem.Save
mItem.Send
'If outlook was not already open, then quit
If Not bOutlookFound Then oApp.Quit
Set oApp = Nothing
End Sub