转载http://www.51testing.com/?uid-197386-action-viewspace-itemid-91560
On error resume next
datatable.GlobalSheet.DeleteParameter "num"
'实际Global表中没有num这个字段,运行时会报错.
If err.number <> 0 Then
createlog
"C:\error.txt","Error",err.descrīption
End If
Function createlog(filepath,logtype,logdetail)
'该脚本用于输出LOG
FilePath =
filepath 'LOG文件的路径
LOGType = logtype 'LOG的类型
LOGDetail =
logdetail 'LOG的内容
Set fso = CreateObject("scrīpting.FileSystemObject")
'判断LOG文件是否存在,如不存在,则按指定路径新建
If fso.FileExists(FilePath) = False Then
Set LOGFile = fso.CreateTextFile(FilePath, True)
LOGFile.Close
end if
Set LOGFile = fso.OpenTextFile(FilePath, 8,
True) '8为追加
LOGFile.WriteLine("")
LOGFile.WriteLine("
---------------------------------------------------------")
LOGFile.WriteLine(" Time:"
& Cstr(Now))
LOGFile.WriteLine(" Type:" & LOGType )
LOGFile.WriteLine(" Detail:" & LOGDetail)
LOGFile.Close
Set LOGFile = nothing
Set fso = nothing
End Function