Thursday, August 18, 2011

Closes all instatnces of open IE browsers

Function Close_All_Browsers()

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colIEProcessList = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")

For Each objProcess in colIEProcessList
objProcess.Terminate()
Next
End Function

This function populates web edit objects with class = dojoComboBox


Function populateDojo (object, sParameter)
   Dim WshShell, sNewParameter

sNewParameter = mid(sParameter,1,len(sParameter)-1)
Set WshShell = CreateObject("WScript.Shell")
wait(2)
object.Click
    WshShell.SendKeys sNewParameter
Wait (3)'Give time for AJAX call to return
WshShell.SendKeys "{DOWN}"
Wait (1)
WshShell.SendKeys "{TAB}"
Wait (3)'Give time for AJAX call to return
Set WshShell = nothing
End Function

Function to "type" into web edits rather than using .set

Function objectType(objObject, parameter)
   On Error Resume Next
   objObject.Click
   Set oShell = CreateObject("WScript.Shell")
   oShell.SendKeys parameter
   oShell.SendKeys("{TAB}")
   Set oShell = Nothing
   If Err.Number = 0 Then
      objectType = True
   Else
      Reporter.ReportEvent micFail, "objectType", "Error # " & CStr(Err.Number) & "Error Detail: " & Err.Description & "Error source: " & Err.Source
      Err.Clear
      objectType = False
   End If
   On Error GoTo 0
End Function

You can call this function as
objectType(UserName, Arun)