Does anybody no a command or code for closing all website windows that are open?
Below is the code that I am using and because we use and reuse this search I want to clear out any open websites that weren't closed...
Thanks in advance.
Sub SpeedSearch()
Dim objIERev
Dim objIEWP
Dim objIEMD
Dim objIEGov
Dim objIEFSMB
Dim objIEGoogle
Dim objIENPI
'************Quotation
Dim myCell As Range
'************
Set objIERev = CreateObject("InternetExplorer.Application")
objIERev.Visible = False
Set objIEWP = CreateObject("InternetExplorer.Application")
objIEWP.Visible = False
Set objIEMD = CreateObject("InternetExplorer.Application")
objIEMD.Visible = False
Set objIEGov = CreateObject("InternetExplorer.Application")
objIEGov.Visible = False
Set objIEFSMB = CreateObject("InternetExplorer.Application")
objIEFSMB.Visible = False
Set objIEGoogle = CreateObject("InternetExplorer.Application")
objIEGoogle.Visible = False
Set objIENPI = CreateObject("InternetExplorer.Application")
objIENPI.Visible = False
'************************Application Activate
Set WshShell = CreateObject("WScript.Shell")
'******************************************
'Whitepages.com
objIEWP.navigate2 "objIEWP.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIEWP.busy
Wend
objIEWP.Visible = True
WshShell.AppActivate "Name or Category"
Name = Range("I8")
WshShell.SendKeys Name
'******************last name
WshShell.SendKeys "{TAB}"
Name = Range("I9")
WshShell.SendKeys Name
'**************zip
WshShell.SendKeys "{TAB}"
Name = Range("I14")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'**************
'Medicare.gov
objIEGov.navigate2 "objIEGov.Visible = True
Application.Wait (Now + TimeValue("0:00:3"))
While objIEGov.busy
Wend
objIEGov.Visible = True
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:2"))
'***************Zip
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Enter}"
Application.Wait (Now + TimeValue("0:00:2"))
'******************Physician
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Enter}"
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:2"))
'************************Zip Search
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "%(L)"
WshShell.SendKeys "{Tab}"
WshShell.AppActivate "Name or Category"
Name = Range("I9")
WshShell.SendKeys Name
'Google.com
objIEGoogle.navigate2 "objIEGoogle.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIEGoogle.busy
Wend
objIEGoogle.Visible = True
'****************Google Quotes*****************Sub AddQuote()
For Each myCell In Range("J8")
Range("J8") = Range("I8") & " " & Range("I9")
If myCell.Value <> " " Then
myCell.Value = Chr(34) & myCell.Value & Chr(34)
End If
Next myCell
'**********************************************
WshShell.AppActivate "Name or Category"
Name = Range("J8") & " " & Range("I15") & " " & Range("I13")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'************************
'WebMD.com
objIEMD.navigate2 "objIEMD.Visible = True
Application.Wait (Now + TimeValue("0:00:2"))
While objIEMD.busy
Wend
objIEMD.Visible = True
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:2"))
'****************Zip
WshShell.AppActivate "Name or Category"
Name = Range("I14")
WshShell.SendKeys Name
'****************Last Name
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
Name = Range("I9")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'FSMB.org
objIEFSMB.navigate2 "objIEFSMB.Visible = True
'Revolutionhealth.com
'*******************Rev Search
objIERev.navigate2 "objIERev.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIERev.busy
Wend
objIERev.Visible = True
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:1"))
'***************Zip
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.AppActivate "Name or Category"
Name = Range("I14")
WshShell.SendKeys Name
'*********************100miles
WshShell.SendKeys "{Tab}"
Name = 11
WshShell.SendKeys Name
'****************Last Name
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
Name = Range("I9")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'************
'NPI Registry
objIENPI.navigate2 "objIENPI.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIENPI.busy
Wend
objIENPI.Visible = True
WshShell.AppActivate "Name or Category"
'**************NPI Number
Application.Wait (Now + TimeValue("0:00:2"))
WshShell.AppActivate "Name or Category"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
If Range("I10") <> 0 Then
WshShell.SendKeys Range("I10")
Else
WshShell.SendKeys "{Tab}"
WshShell.SendKeys Range("I8")
WshShell.SendKeys "{Tab}"
WshShell.SendKeys Range("I9")
End If
WshShell.SendKeys "{Enter}"
End Sub
Below is the code that I am using and because we use and reuse this search I want to clear out any open websites that weren't closed...
Thanks in advance.
Sub SpeedSearch()
Dim objIERev
Dim objIEWP
Dim objIEMD
Dim objIEGov
Dim objIEFSMB
Dim objIEGoogle
Dim objIENPI
'************Quotation
Dim myCell As Range
'************
Set objIERev = CreateObject("InternetExplorer.Application")
objIERev.Visible = False
Set objIEWP = CreateObject("InternetExplorer.Application")
objIEWP.Visible = False
Set objIEMD = CreateObject("InternetExplorer.Application")
objIEMD.Visible = False
Set objIEGov = CreateObject("InternetExplorer.Application")
objIEGov.Visible = False
Set objIEFSMB = CreateObject("InternetExplorer.Application")
objIEFSMB.Visible = False
Set objIEGoogle = CreateObject("InternetExplorer.Application")
objIEGoogle.Visible = False
Set objIENPI = CreateObject("InternetExplorer.Application")
objIENPI.Visible = False
'************************Application Activate
Set WshShell = CreateObject("WScript.Shell")
'******************************************
'Whitepages.com
objIEWP.navigate2 "objIEWP.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIEWP.busy
Wend
objIEWP.Visible = True
WshShell.AppActivate "Name or Category"
Name = Range("I8")
WshShell.SendKeys Name
'******************last name
WshShell.SendKeys "{TAB}"
Name = Range("I9")
WshShell.SendKeys Name
'**************zip
WshShell.SendKeys "{TAB}"
Name = Range("I14")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'**************
'Medicare.gov
objIEGov.navigate2 "objIEGov.Visible = True
Application.Wait (Now + TimeValue("0:00:3"))
While objIEGov.busy
Wend
objIEGov.Visible = True
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:2"))
'***************Zip
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Enter}"
Application.Wait (Now + TimeValue("0:00:2"))
'******************Physician
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Enter}"
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:2"))
'************************Zip Search
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "%(L)"
WshShell.SendKeys "{Tab}"
WshShell.AppActivate "Name or Category"
Name = Range("I9")
WshShell.SendKeys Name
'Google.com
objIEGoogle.navigate2 "objIEGoogle.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIEGoogle.busy
Wend
objIEGoogle.Visible = True
'****************Google Quotes*****************Sub AddQuote()
For Each myCell In Range("J8")
Range("J8") = Range("I8") & " " & Range("I9")
If myCell.Value <> " " Then
myCell.Value = Chr(34) & myCell.Value & Chr(34)
End If
Next myCell
'**********************************************
WshShell.AppActivate "Name or Category"
Name = Range("J8") & " " & Range("I15") & " " & Range("I13")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'************************
'WebMD.com
objIEMD.navigate2 "objIEMD.Visible = True
Application.Wait (Now + TimeValue("0:00:2"))
While objIEMD.busy
Wend
objIEMD.Visible = True
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:2"))
'****************Zip
WshShell.AppActivate "Name or Category"
Name = Range("I14")
WshShell.SendKeys Name
'****************Last Name
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
Name = Range("I9")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'FSMB.org
objIEFSMB.navigate2 "objIEFSMB.Visible = True
'Revolutionhealth.com
'*******************Rev Search
objIERev.navigate2 "objIERev.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIERev.busy
Wend
objIERev.Visible = True
WshShell.AppActivate "Name or Category"
Application.Wait (Now + TimeValue("0:00:1"))
'***************Zip
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.AppActivate "Name or Category"
Name = Range("I14")
WshShell.SendKeys Name
'*********************100miles
WshShell.SendKeys "{Tab}"
Name = 11
WshShell.SendKeys Name
'****************Last Name
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
Name = Range("I9")
WshShell.SendKeys Name
WshShell.SendKeys "{Enter}"
'************
'NPI Registry
objIENPI.navigate2 "objIENPI.Visible = True
Application.Wait (Now + TimeValue("0:00:1"))
While objIENPI.busy
Wend
objIENPI.Visible = True
WshShell.AppActivate "Name or Category"
'**************NPI Number
Application.Wait (Now + TimeValue("0:00:2"))
WshShell.AppActivate "Name or Category"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
WshShell.SendKeys "{Tab}"
If Range("I10") <> 0 Then
WshShell.SendKeys Range("I10")
Else
WshShell.SendKeys "{Tab}"
WshShell.SendKeys Range("I8")
WshShell.SendKeys "{Tab}"
WshShell.SendKeys Range("I9")
End If
WshShell.SendKeys "{Enter}"
End Sub