Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

_Excel UDF to ADODB

$
0
0

Hi Guys,

 

I have the following code. But it needs Excel program to be installed on the machine in order to execute it successfully.

Can someone guide me as to how I can bypass this using ADODB?

 

Thank you.

AutoIt         
#NoTrayIcon Global $E = IniReadSection("idcollate.ini", "Events") If @error Then     MsgBox(4096, "", "Error occurred, probably no INI file.") Else     For $k = 1 To $E[0][0]         Global $S = IniReadSection("idcollate.ini", "EventID")         If @error Then             MsgBox(4096, "", "Error occurred, probably no INI file.")         Else             For $j = 1 To $S[0][0]                 Global $var = IniReadSection("idcollate.ini", "Type")                 If @error Then                     MsgBox(4096, "", "Error occurred, probably no INI file.")                 Else                     For $i = 1 To $var[0][0]                         Global $Serve = IniReadSection("idcollate.ini", "Servers")                         If @error Then                             MsgBox(4096, "", "Error occurred, probably no INI file.")                         Else                             For $V = 1 To $Serve[0][0]                                 $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & $Serve[$V][1] & "\root\cimv2")                                 ;MsgBox(0, "", "Select * FROM Win32_NTLogEvent WHERE Logfile = " & "'" & $E[$k][1] & "'" & " AND Type = " & "'" & $var[$i][1] & "' " & "AND EventCode = " & $S[$j][1])                                 $Query_Clause = "Select * FROM Win32_NTLogEvent WHERE Logfile = " & "'" & $E[$k][1] & "'" & " AND Type = " & "'" & $var[$i][1] & "' " & "AND EventCode = " & $S[$j][1]                                 If IsObj($objWMIService) Then                                     $colItems = $objWMIService.ExecQuery($Query_Clause)                                     If IsObj($colItems) Then                                         For $objEvent In $colItems                                             $Output = ""                                             ;$Output &= "Category: " & $objEvent.Category & @CRLF                                             ;$Output &= "Computer Name: " & $objEvent.ComputerName & @CRLF                                             ;$Output &= "Event Code: " & $objEvent.EventCode & @CRLF                                             ;$Output &= "Message: " & $objEvent.Message & @CRLF                                             ;$Output &= "Record Number: " & $objEvent.RecordNumber & @CRLF                                             ;$Output &= "Source Name: " & $objEvent.SourceName & @CRLF                                             ;$Output &= "Time Written: " & $objEvent.TimeWritten & @CRLF                                             ;$Output &= "Event Type: " & $objEvent.Type & @CRLF                                             ;$Output &= "User: " & $objEvent.User & @CRLF                                             ;MsgBox(0, "", @ScriptDir & "\" & $Serve[$V][1] & ".txt")                                             Local $file = FileOpen(@ScriptDir & "\" & $Serve[$V][1] & "_" & @MDAY & @MON & @YEAR & ".txt", 1)                                             ; Check if file opened for writing OK                                             If $file = -1 Then                                                 MsgBox(0, "Error", "Unable to open file.")                                                 Exit                                             EndIf                                             $Msg = StringStripWS($objEvent.Message, 4)                                             $Msg2 = StringStripCR($Msg)                                             FileWrite($file, $objEvent.ComputerName & ";" & $objEvent.EventCode & ";" & $Msg2 & ";" & $objEvent.SourceName & ";" & $objEvent.TimeWritten & ";" & $objEvent.Type & @CRLF)                                             FileClose($file)                                             ;If MsgBox(64 + 4, "Entry Found:", $Output & @CRLF & @CRLF & "Continue?") = 7 Then Exit                                         Next                                     Else                                         MsgBox(16, "Error", "$colItems is not an object.")                                     EndIf                                 Else                                     MsgBox(16, "Error", "$objWMIService is not an object.")                                 EndIf                             Next                         EndIf                     Next                 EndIf             Next         EndIf     Next EndIf MsgBox(0, "", "End.") Exit

Viewing all articles
Browse latest Browse all 12506

Trending Articles