Monday, February 7, 2011

Close all open browser before start execution

Public Function CloseAllBrowsers()


     'Create a description for browser
      Set oBrowser = Description.Create
      oBrowser("micclass").Value = "Browser"
      Set oPage = Description.Create
      oPage("micclass").Value = "Page"
      'Get all browsers
      Set allBrowser = Desktop.ChildObjects(oBrowser)
      Dim i, iCount
      iCount = allBrowser.Count - 1
      For i = 0 To iCount
            'Get the page object from the browser
            Set oPg = allBrowser(i).ChildObjects(oPage)(0)
            allBrowser(i).Close
     Next

End Function

No comments: