VBA get information from website after reload to post state.

Bassik

New Member
Joined
Dec 20, 2019
Messages
4
Office Version
  1. 2007
Platform
  1. Windows
  2. Web
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.

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.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top