Hello people!
First - i'm new in this forum as registeret user but this site help me a lot .
My english is wery weak but i try my best so .
I have in Excel workbook macro to recive information about track shipment's from site's like :
Śledzenie przesyłek InPost | InPost - Paczkomaty, Kurier, Przesyłki Kurierskie
etc.
Now i get new (for us of cource) company site and i can not figure out solution to get info from it.
Using code below allows me to open this site in the form i need to read information manualy but
what i want is to get info , back to the worksheet.
I know the problem it's be a __VIEWSTATE of this page but never do this before and need some solution's for start.
I will be grateful for any help.
First - i'm new in this forum as registeret user but this site help me a lot .
My english is wery weak but i try my best so .
I have in Excel workbook macro to recive information about track shipment's from site's like :
myDSV
Fast and easy booking, tracking and support. Air, sea and road shipments. More transparency and control. Online access to related documents.
mydsv.com
Śledź przesyłkę – sprawdź postęp realizacji | TNT Poland
Możesz łatwo śledzić online swoje przesyłki. Otrzymuj na bieżąco szczegółowe informacje o postępie realizacji wszystkich przesyłek.
www.tnt.com
etc.
Now i get new (for us of cource) company site and i can not figure out solution to get info from it.
Using code below allows me to open this site in the form i need to read information manualy but
what i want is to get info , back to the worksheet.
VBA Code:
Private Declare Function ShowWindow Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdSHow As Long) As Long
Global Const SW_SHOWMAXIMIZED = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Sub TrackingRHENUS() ' (adrRow As Integer, adrKol As Integer, adrStatus As Integer) - I'm use this values from sheet
Dim URL As String
Dim ie As InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim TDelements As IHTMLElementCollection
Dim TDelement As HTMLTableCell
Dim r As Long
Dim Shell As Object
Dim zakonczono As Boolean
On Error GoTo Sub_exit
' This part of code is checking actual status of package
'If Cells(adrRow, adrStatus).Value = "On the way" Or Cells(adrRow, adrStatus).Value = "" Then
'zakonczono = False
'Else
'zakonczono = True
'End If
URL = "http://espeed.rhenus.com.pl/"
numerListu = "p/38/591671/2019" ' It's an exemple number rest of numbers is in sheet - Cells(adrRow, adrKol).Value
Set ie = New InternetExplorer
With ie
.Navigate URL
.Visible = True
ShowWindow .hwnd, SW_SHOWMAXIMIZED
'Wait for page to load
While .Busy Or .ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set HTMLDoc = .Document
End With
Application.Wait Now + TimeValue("00:00:02")
Set TDelements = HTMLDoc.getElementsByTagName("Input")
For Each TDelement In TDelements
If Right(TDelement.ID, 5) = "TB0_I" Then
TDelement.Focus
TDelement.Value = ""
While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
For i = 1 To Len(numerListu)
Application.SendKeys Mid(numerListu, i, 1)
While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend ' Withouth this part server recives part of number
Next
TDelement.FireEvent ("onkeyup")
TDelement.FireEvent ("onfocus")
TDelement.FireEvent ("onkeydown")
While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
'Cells(adrRow, ThisWorkbook.kolTracking).Value = "It's Open" - This is information when already clik the link an open site
Exit For
End If
Next
While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
While ie.ReadyState <> 4
DoEvents
Wend
Set TDelements = HTMLDoc.getElementsByTagName("td")
For Each TDelement In TDelements
If TDelement.ID = "ctl00_ContentPlaceHolder2_ASPxPageControl1_TT_T&T/_ledzeniestatus_wPNLYTSEJAM_TT_T&T/_ledzeniestatus_wBTQYTSEJAM_B" Then
TDelement.FireEvent ("onmouseover")
TDelement.Click
End If
Next
While ie.ReadyState <> 4
DoEvents
Wend
Application.Wait Now + TimeValue("00:00:02")
ShowWindow ie.hwnd, SW_SHOWMINIMIZED
Set ie = Nothing
Done:
Exit Sub
Sub_exit:
MsgBox "Error server connection. Try again later."
End Sub
I know the problem it's be a __VIEWSTATE of this page but never do this before and need some solution's for start.
I will be grateful for any help.