如何将Excel报告的开始写入事件日志
我希望Excel VBA将宏启动时的开始写入事件日志。它是通过服务器启动的。这将向Windows应用程序事件日志写入一条消息:如何将Excel报告的开始写入事件日志,excel,vba,Excel,Vba,我希望Excel VBA将宏启动时的开始写入事件日志。它是通过服务器启动的。这将向Windows应用程序事件日志写入一条消息: Public Enum EventType xlLogSuccess = 0 xlLogError = 1 xlLogWarning = 2 xlLogInformation = 4 xlLogAudit_Success = 8 xlLogAudit_Failure = 16 End Enum Sub WriteEve
Public Enum EventType
xlLogSuccess = 0
xlLogError = 1
xlLogWarning = 2
xlLogInformation = 4
xlLogAudit_Success = 8
xlLogAudit_Failure = 16
End Enum
Sub WriteEventLog(ByVal sLogMessage As String, Optional ByVal iLogType As Integer)
Dim wso As Object
Set wso = CreateObject("WScript.Shell")
wso.LogEvent iLogType, sLogMessage
End Sub
Sub Test()
WriteEventLog "My log message", xlLogAudit_Success
End Sub
事件日志是指windows事件日志?不,报告服务器上有一个日志文件。事件日志在哪里?真的吗?你的问题是如何写信给它。。。你能给我解释一下这些变量吗?xlLogSuccess=0 xlLogError=1 xlLogWarning=2 xlLogInformation=4 xlLogAudit\u Success=8 xlLogAudit\u Failure=16我刚刚声明了一个枚举变量,以便更容易识别您传递的事件类型。在编写/调试时,xlLogInformation比4提供更多信息。现在我想把一个in-script变量的值交给你,我试着用WriteEventLog将副本保存到目标目录!ID:&变量,但它不起作用:/