Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internet Explorer - UPS tracking 1

Status
Not open for further replies.

Losman500

Technical User
Oct 9, 2007
43
US
I wrote an Extra! macro that goes to different shipping sites and enters screen data into their tracking forms. All of them work but for some reason in the UPS site I cannot figure out how to "click" the track button. Maybe someone here knows how to.

Here is an excerpt of my code which only puts the screen value on the tracking form but does not "click" the track button:

Code:
Case is = "UP"  
        Set IE = CreateObject("InternetExplorer.Application")   
        With IE
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://www.ups.com/WebTracking/track?loc=en_US&WT.svl=PNRO_L1"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
        Wend
        While IE.Document.ReadyState <> "complete"
        'Again Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.trkinput.trackNums.value = Tracking
        IE.Document.Forms.trkinput.Submit
        Set IE = Nothing
Within the trkinput form is this object:
<input class="btn_a" name="track.x" type="submit" value="Track">
which is the "track" button but I can figure out how to click it.
I tried this but it didn't work

Code:
IE.Document.Forms.trkinput.item("track.x").click

Any ideas?
 
I figured it out. Just like the previous post, I needed to wait before clicking the form

Here is the working code:

Code:
Case is = "UP"  
        Set IE = CreateObject("InternetExplorer.Application")   
        With IE
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://www.ups.com/WebTracking/track?loc=en_US&WT.svl=PNRO_L1"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.trkinput.trackNums.value = Tracking
        IE.Document.Forms.trkinput.Submit
        While IE.Document.ReadyState <> "complete"
        Wend
        IE.Document.Forms.trkinput.item("track.x").click
        Set IE = Nothing
 
apparently this code is incomplete because it doesn't work at all the way it is here.
 
This code works for me, just change the references to the screen to suit your system
Here is the complete code:
Code:
 Sub Main()
   
   Dim Sys as Object, Sess As Object    
   Set Sys = CreateObject("Extra.System")   
    If Sys is Nothing then
        MsgBox ("Could not create Extra!.System...is E!PC installed in this machine?")
        Exit Sub
    End If   
    Set Sess = Sys.ActiveSession   
    If Sess Is Nothing then 
        MsgBox ("No Session Available...Stopping Macro playback.")
        Exit Sub
    End If
	
	Dim IE as Object
	Dim IEpage As Object
	If UCase(Sess.Screen.GetString(1, 2, 4)) = "SHPQ" OR UCase(Sess.Screen.GetString(1, 2, 4)) = "SHPM" Then
 
	Select case Sess.Screen.Getstring(22,02,2)
    Case is = "FE"   
        Set IE = CreateObject("InternetExplorer.Application")  
        With IE
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://www.fedex.com/Tracking?cntry_code=us"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.Tracking.tracknumbers.value = Tracking
        IE.Document.Forms.Tracking.submit
        Set IE = Nothing   
        
    Case is = "UP"  
        Set IE = CreateObject("InternetExplorer.Application")   
        With IE
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://www.ups.com/WebTracking/track?loc=en_US&WT.svl=PNRO_L1"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.trkinput.trackNums.value = Tracking
        IE.Document.Forms.trkinput.Submit
        Set IE = Nothing    
          
    Case is = "AB"   
        Set IE = CreateObject("InternetExplorer.Application")  
        With IE 
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://www.abfs.com/default.asp"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.frmQuickTools.txtRef.value = Tracking
        IE.Document.Forms("frmQuickTools").all.item("cmdTrack").Click 
        Set IE = Nothing
        
        
           Case is = "AN"   
        Set IE = CreateObject("InternetExplorer.Application")  
        With IE 
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://www.airnet.com/Tracking/shiplink.htm"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Trim(Sess.Screen.GetString(22, 7,18))
        IE.Document.Forms.FormTrack.as_AirbillNum.value = Tracking
        While IE.Document.ReadyState <> "complete"
        Wend
        Set IE = Nothing
        
        
    Case is = "DH"   
        Set IE = CreateObject("InternetExplorer.Application")  
        With IE 
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://track.dhl-usa.com/TrackByNbr.asp?nav=TrackBynumber"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.frmTrackByNbr.txtTrackNbrs.value = Tracking
        IE.Document.Forms.frmTrackByNbr.SUBMIT 
        Set IE = Nothing 
        
    Case is = "AX"   
        Set IE = CreateObject("InternetExplorer.Application")  
        With IE 
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://axisg.com/webtrak/shipinquiry/shiplookup.aspx"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.Form1.txtHndStation.value = Tracking
        SendKeys "{enter}"
        Set IE = Nothing
        
    Case is = "CO" 
        If UCase(Sess.Screen.GetString(22, 2, 2)) = "CO" then  
        Set IE = CreateObject("InternetExplorer.Application")  
        With IE 
            .AddressBar = False
            .StatusBar = True
            .MenuBar = False
            .Toolbar = 0
            .Visible = True
            .Navigate "[URL unfurl="true"]http://cargo.cocargo.com/cargo/track/"[/URL]        
        End With
        While IE.Busy
        'Do Nothing
    
    
    Wend
        While IE.Document.ReadyState <> "complete"
        'AgaIn Do Nothing
        Wend
        Tracking =  Sess.Screen.GetString(22, 7,18)
        IE.Document.Forms.aspnetForm.ctl00_cpRight_txtTrack.value = Tracking
        IE.Document.Forms("aspnetForm").all.item("btnTrack").Click
        Set IE = Nothing
        
    
        Else
            MsgBox "Could not verify Carrier. If this is a Continental AWB please visit [URL unfurl="true"]www.cocargo.com"[/URL]
        End If
 
        
    Case ELSE
        msgbox ("Cannot find appropiate webpage - Unable to Track")
        END SELECT

     Else
      MsgBox "You must be in the SHPQ to Run Macro"    ' Displays a message box if not is SHPQ
   End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top