link to a DHL tracking site

C

cbrah

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.
 
T

Tim Williams

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top