Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将Excel报告的开始写入事件日志_Excel_Vba - Fatal编程技术网

如何将Excel报告的开始写入事件日志

如何将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

我希望Excel VBA将宏启动时的开始写入事件日志。它是通过服务器启动的。

这将向Windows应用程序事件日志写入一条消息:

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:&变量,但它不起作用:/