ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   link to a DHL tracking site (https://www.excelbanter.com/excel-programming/324550-link-dhl-tracking-site.html)

cbrah

link to a DHL tracking site
 
I need to create a link that will take a airbill tracking number I have
listed in column "C3" and when clicked, go to the status screen of the DHL
tracking website.
This is the site:
http://track.dhl-usa.com/TrackByNbr.asp
This is an example of a tracking number 38821115060
When I create the link I wind up at the home page, not the tracked info page.
Any suggestions would get me out of hot water.

Tim Williams

link to a DHL tracking site
 
Try this. Place a button on the sheet and link it to GetTrackingInfo.
Select a cell with a tracking number and click the button.


'add references to
' Microsoft Internet Controls
' Microsoft HTML Object Library

Sub GetTrackingInfo()


Dim IEObj As Object

Const S_URL As String = "http://track.dhl-usa.com/TrackByNbr.asp"
Dim doc As MSHTML.HTMLDocument
Dim s As String

If trim(ActiveCell.Value) < "" Then
s = Trim(ActiveCell.Value)
Else
Exit Sub
End If

Set IEObj = GetIE()
IEObj.Navigate S_URL
Do While IEObj.ReadyState < READYSTATE_COMPLETE
Loop
Set doc = IEObj.Document
doc.frmTrackByNbr.txtTrackNbrs.Value = s
doc.frmTrackByNbr.submit

End Sub

Function GetIE() As Object


Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As Object, sURL As String


Set retVal = Nothing
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows

'see if IE is already open
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.Document.Location
On Error GoTo 0
If sURL < "" Then
Set retVal = o
Exit For
End If
Next o

If retVal Is Nothing Then
Set retVal = New InternetExplorer
retVal.Visible = True
End If

Set GetIE = retVal
End Function

"cbrah" wrote in message
...
I need to create a link that will take a airbill tracking number I
have
listed in column "C3" and when clicked, go to the status screen of
the DHL
tracking website.
This is the site:
http://track.dhl-usa.com/TrackByNbr.asp
This is an example of a tracking number 38821115060
When I create the link I wind up at the home page, not the tracked
info page.
Any suggestions would get me out of hot water.





All times are GMT +1. The time now is 07:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com