My code follows.
Sub AppGIS()
Dim CellValue
Dim CMValue
Dim CMClaim
Dim compareme
'Define ClaimNumber
CellValue = Selection.Cells.Value
'Check for CM Claim
compareme = CellValue Like "????????/?"
If compareme = True Then GoTo CM
'Check for Payment Number
compareme = CellValue Like "#######"
If compareme = True Then GoTo Payment
'If Not CM or Payment, is DM
GoTo DM
'Set Commercial Claim format
CM:
CMValue = Left(CellValue, 8)
CMClaim = Right(CellValue, 1)
'Switch to GIS
AppActivate ("Host4 - EXTRA! for SNA Server")
SendKeys ("CM.QCL{ENTER}")
'Wait 2 Seconds
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
'Enter Claim number into GIS
SendKeys ("{TAB}" & CMValue & "{TAB}" & CMClaim)
SendKeys ("{ENTER}")
GoTo EndMe
DM:
'Switch to GIS
AppActivate ("Host4 - EXTRA! for SNA Server")
SendKeys ("DM.QCL{ENTER}")
'Wait 2 Seconds
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
'Clear Claim and Enter DM Claim Number into GIS
SendKeys ("{TAB} {TAB}{TAB}" & CellValue)
SendKeys ("{ENTER}")
GoTo EndMe
Payment:
'Alert payment
MsgBox ("This Reference Number is a Payment. Please query Manually")
'Switch To GIS
AppActivate ("Host4 - EXTRA! for SNA Server")
EndMe:
'Completed Successfully.
Beep
End Sub
Thanks for your help.
-Bo