Track A Package

Share actions you've created here.
Post Reply
Posts: 12
Joined: Wed Jul 06, 2011 2:16 pm

Track A Package

Post by Austin » Wed Jul 20, 2011 4:13 pm

This Action will lookup the tracking number currently on your clipboard and display the results from the carrier in a browser window.

Language: VBScript

Code: Select all

'Author: Austin James
'Date:   7/10/2011

'This action will take a single tracking number from UPS, FedEX, or the United States Postal Service (USPS) and
'perform a lookup of the status of the package.  The lookup will be displayed in a browser window.

'Tracking number format definitions derived from

'Initialize Variables
Dim wShell
Dim trackURL
Dim trackNum
Dim re
Dim isUPSnum
Dim isFedEXnum
Dim isUSPSnum
Dim trackNumTypeFound
'Remove spaces from tracking number for URL
trackNum = Replace(Clipboard.Value," ","")
'Set initial values for boolean check variables
isupsnum = False
isfedexnum = False
isuspsnum = False
trackNumTypeFound = False
'If the tracking number is numeric, determine which carrier the tracking number belongs to via length
If isnumeric(trackNum) Then
   Select Case len(trackNum)
      Case 11 '11 character numeric tracking numbers are from UPS
         isUPSnum = True
         trackNumTypeFound = True
      Case 12 '12 character numeric tracking numbers are from FedEX
         isFedEXnum = True
         trackNumTypeFound = True
      Case 15 '15 character numeric tracking numbers are from FedEX
         isFedEXnum = True
         trackNumTypeFound = True
      Case Else 'All other tracking numbers are probably from USPS
         isUSPSnum = True
         trackNumTypeFound = True
   End Select
Else 'If there are non numeric characters in tracking number check for UPS '1Z...' pattern
   Set re = New RegExp
   re.pattern = "^1Z"
   If re.test(trackNum) Then
      isUPSnum = True
      trackNumTypeFound = True
   End If
   Set re = Nothing
End If
'If we know who the carrier is, format the URL for lookup
If isUPSnum Then
   trackURL = ""
ElseIf isFedEXnum Then
   trackURL = ""
ElseIf isuspsnum Then
   trackURL = ""
End If
'If we know the carrier, perform the lookup
'If we do not know the carrier, alert the user.
If trackNumTypeFound Then
   Set wShell = CreateObject("Shell.Application")
   wShell.Open trackURL & trackNum
   Set wShell = Nothing
   MsgBox "Cannot determine what carrier the supplied tracking number belongs to."
End If

Posts: 2
Joined: Sun Feb 19, 2012 3:26 pm

Re: Track A Package

Post by clickerX » Sun Feb 19, 2012 3:28 pm

Awesome! :D

Post Reply