John,
The serial structure of your code means that you will have to test several
times. In the longer term if you are going to build Bloomberg based systems,
you might want to have a look at their api. I think you can find details in
their help section somewhere.
In the meantime, your code would go something like this:
Public UserCancelled as Boolean
Sub BloombergCall()
Dim PB As clsProgBar
Set PB = New clsProgBar
With PB
PB.Title = "Performing Searches in Bloomberg"
PB.Caption1 = "Searches are running, please wait..."
PB.Show
DoEvents
AppActivate ("1-BLOOMBERG"), 2
PB.Progress = 12.5
PB.Caption2 = "Performing 1st Agency Search"
If UserCancelled = TRUE Then Goto EndRoutine
' Ag
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("x3").Value, "MM/DD/YYYY")
SendKeys Format(Range("x3").Value, "MM/DD/YYYY")
SendKeys ("~")
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("1~")
If UserCancelled = TRUE Then Goto EndRoutine
Application.Wait Now + TimeSerial(0, 0, 7)
' Corp
PB.Progress = 25
PB.Caption2 = "Performing 1st Corporate Search"
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("x3").Value, "MM/DD/YYYY")
SendKeys Format(Range("x3").Value, "MM/DD/YYYY")
SendKeys ("~")
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("1~")
If UserCancelled = TRUE Then Goto EndRoutine
Application.Wait Now + TimeSerial(0, 0, 7)
' Start of 2nd Search Date
' Ag
PB.Progress = 37.5
PB.Caption2 = "Performing 2nd Agency Search"
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("y3").Value, "MM/DD/YYYY")
SendKeys Format(Range("y3").Value, "MM/DD/YYYY")
SendKeys ("~")
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("1~")
If UserCancelled = TRUE Then Goto EndRoutine
Application.Wait Now + TimeSerial(0, 0, 7)
' Corp
PB.Progress = 50
PB.Caption2 = "Performing 2nd Corporate Search"
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("y3").Value, "MM/DD/YYYY")
SendKeys Format(Range("y3").Value, "MM/DD/YYYY")
SendKeys ("~")
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("1~")
If UserCancelled = TRUE Then Goto EndRoutine
Application.Wait Now + TimeSerial(0, 0, 7)
' Start of 3rd Search
' Ag
PB.Progress = 62.5
PB.Caption2 = "Performing 3rd Agency Search"
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("z3").Value, "MM/DD/YYYY")
SendKeys Format(Range("z3").Value, "MM/DD/YYYY")
SendKeys ("~")
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("1~")
If UserCancelled = TRUE Then Goto EndRoutine
Application.Wait Now + TimeSerial(0, 0, 7)
' Corp
PB.Progress = 75
PB.Caption2 = "Performing 3rd Corporate Search"
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("z3").Value, "MM/DD/YYYY")
SendKeys Format(Range("z3").Value, "MM/DD/YYYY")
SendKeys ("~")
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("1~")
If UserCancelled = TRUE Then Goto EndRoutine
Application.Wait Now + TimeSerial(0, 0, 7)
' Start of 4th Search
' Ag
PB.Progress = 87.5
PB.Caption2 = "Performing 4th Agency Search"
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("aa3").Value, "MM/DD/YYYY")
SendKeys Format(Range("aa3").Value, "MM/DD/YYYY")
SendKeys ("~")
SendKeys ("srch~")
SendKeys ("1~")
SendKeys ("1~")
If UserCancelled = TRUE Then Goto EndRoutine
Application.Wait Now + TimeSerial(0, 0, 7)
' Corp
PB.Progress = 95
PB.Caption2 = "Performing 4th Corporate Search"
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("8~")
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys Format(Range("aa3").Value, "MM/DD/YYYY")
SendKeys Format(Range("aa3").Value, "MM/DD/YYYY")
SendKeys ("~")
PB.Progress = 98
PB.Caption2 = "Performing 4th Corporate Search"
SendKeys ("srch~")
SendKeys ("2~")
SendKeys ("1~")
SendKeys ("rpt~")
EndRoutine:
PB.Finish
Set PB = Nothing
End Sub
Robin Hammond
www.enhanceddatasystems.com