WPS测试通过,Office兼容。用法简单,把需要log的字符串当作参数直接调用该函数,即可在当前工作表目录下的log.html文件尾部追加带时间戳的记录(用html是因为看着方便)。文件名和内容可以自行修改。log大概长这样:
2021/11/20 07:15:22 Login 2021/11/20 07:15:23 List ready 2021/11/20 07:15:32 Data saved 2021/11/20 07:16:19 Mail sent to: xx@xx.com
Sub writeLog(sLog As String)
scriptFileName = ThisWorkbook.Path & "\log.html"
Open scriptFileName For Append As #1
strLog = Format(Now, "yyyy/mm/dd hh:mm:ss") & " " & sLog
Print #1, strLog
Close #1
End Sub
以上。
KVP的老狼
Y