我目前有一个生成客户报表的 Excel 文件。我需要跟踪谁运行了他们的报表。
目前,每当生成语句时,我都会有一个宏向我发送一封包含其用户名的电子邮件。然而,在瘦客户端系统上运行的人们会收到提示;
“一个程序正在尝试代表您发送电子邮件......”
有什么方法可以摆脱这个提示并仍然发送电子邮件,或者有人对如何跟踪使用情况有任何其他想法。我通过 Share Point 共享文件。那么它可能有一些功能吗?
谢谢
如果您的网络上有一个位置每个人都可以访问,您可以写入日志文件。最有可能是 Sharepoint 服务器上的一个位置。
类似这样的事情是从当前发送电子邮件的代码中调用的。
在 VBA IDE 中,转到工具菜单并选择引用。选择“Microsoft 脚本运行时”
Private Sub LogUsage()
Dim ts As TextStream
Dim fs As FileSystemObject
Dim strLogFile As String
strLogFile = "\\servername\sharename\log\Usage.txt"
'Check if the file exists, if it does, open it, if it doesn't create it
Set fs = New FileSystemObject
If fs.FileExists(strLogFile) = True Then
Set ts = fs.OpenTextFile(strLogFile, ForAppending)
Else
Set ts = fs.CreateTextFile(strLogFile, True, False)
End If
'Log your entry
ts.WriteLine "Used by " & Environ$("Username") & " at " & Now & " on computer " & Environ$("Computername")
'Clean up
ts.Close: Set ts = Nothing
Set fs = Nothing
End Sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)