Forum

Excel ile Ptt Barko...
 
Bildirimler
Hepsini Temizle

Excel ile Ptt Barkod Sorgulama

3 Yazılar
2 Üyeler
0 Likes
5,218 Görüntüleme
(@Anonim)
Gönderiler: 0
Konu başlatıcı
 

[b]Excel[/b]'de bir hücreye barkod numarası girerek, gönderdiğiniz ya da alıcısı olduğunuz kargonun o ana kadar ki durumunu sayfaya aktarabilirsiniz. 

Sonucu resimde görebilirsiniz.. 
[img] [/img]
Sayfanızdaki formatı resimde gördüğünüz formata ayarlarsanız ve [b]H2[/b] hücresine de sorgulamak istediğiniz [b]Barkod No[/b]'yu yazarsanız, hatasız bir şekilde sorgulama yapıp döküm alabilirsiniz.. 

■ [b]Uygulama için bu kodları kullanabilirsiniz;[/b]

Private Declare Function InternetCheckConnection Lib "wininet.dll" _
    Alias 
"InternetCheckConnectionA" (ByVal lpszUrl As String_
    ByVal dwFlags 
As LongByVal dwReserved As Long) As Long
Private Declare Function Murat_OSMA Lib "user32" Alias _
    
"ShowWindow" (ByVal hwnd As LongByVal nCmdShow As Long) As Long

Sub Ptt_Barkod_Sorgulama
()
    
Dim URL As StringIE As ObjectdocX As Object
    Dim i 
As IntegerAs IntegerAs Integer
    
    Range
("B2:B8").ClearContents
    Range
("D2:D8").ClearContents
    Range
("A10:D" Range("D65536").End(3).Row).Interior.ColorIndex 0
    Range
("A10:D1000").ClearContents
    URL 
"https://www.turkiye.gov.tr/ptt-gonderi-takip"
    
If (InternetCheckConnection(URL "/", &H10&) = 0Then _
        MsgBox 
"internet bağlantısı yok": Exit Sub
    Set IE 
CreateObject("InternetExplorer.Application")
    
With IE
        
.Navigate URL
        
.Visible True
        Murat_OSMA 
.hwnd2
    
Do While .BusyDoEventsLoop
    
Do Until .ReadyState 4DoEventsLoop
        
.Document.all.barkod.Value Range("H2").Value
        
.Document.forms("mainForm").submit
    
Do While .BusyDoEventsLoop
    
Do Until .ReadyState 4DoEventsLoop
      Range
("B2").Value = .Document.all.Item(88).innertext
      Range
("B3").Value = .Document.all.Item(90).innertext
      Range
("B4").Value = .Document.all.Item(92).innertext
      Range
("B5").Value = .Document.all.Item(94).innertext
      Range
("B6").Value = .Document.all.Item(96).innertext
      Range
("B7").Value = .Document.all.Item(98).innertext
      Range
("B8").Value = .Document.all.Item(100).innertext
      Range
("D3").Value = .Document.all.Item(102).innertext
      Range
("D4").Value = .Document.all.Item(104).innertext
      Range
("D5").Value = .Document.all.Item(106).innertext
      Range
("D8").Value = .Document.all.Item(108).innertext
    On Error Resume Next
    
For 0 To 1
        
If InStr(1, .Document.getelementsbytagname("TABLE")(i).innertext"No"vbTextCompare) > 0 Then
            Set docX 
= .Document.getelementsbytagname("TABLE")(i)
            
8
            
For Each tr In docX.all.tags("TR")
                
1
                
For 0 To tr.all.tags("TD").Length 1
                    Cells
(c1) = tr.all.tags("TD").Item(j).innertext
                Next j
            Next tr
        End 
If
    
Next i
    Range
("A9:D" Range("D65536").End(3).Row).Style "İyi"
    
End With
    Columns
.AutoFit
    IE
.Quit
    Set IE 
NothingSet docX NothingURL ""= Empty: = Empty: = Empty
End Sub

[u]Bilmeyenler için anlatım yapayım:[/u]
Excel'i açın ve sayfadayken ALT+F11 tuşlarına birlikte basın. 
Açılan pencerenin üst menüsünden önce Insert sonra da Module seçin ve kodları açılan boş pencereye yapıştırın. Şimdi makroda herhangi bir satırı
 seçin ve F5 tuşuna basın. 

Faydalı olması dileğiyle... 

Hoşça kalın ! --)(

 
Gönderildi : 19/11/2013 13:55

(@sinankahraman)
Gönderiler: 5225
Illustrious Member
 

Teşekkür ederiz.

 
Gönderildi : 20/11/2013 11:23

(@Anonim)
Gönderiler: 0
Konu başlatıcı
 

Rica ederim [b]Sinan Bey[/b],

Bu arada, "https://www.turkiye.gov.tr/ptt-gonderi-takip" adresinden 1 saat için en fazla 50 barkod sorgusu yapılabiliyor. 
50'den fazla barkod sorgulamak için bu adres kullanılabilir; "https://wap.ptt.gov.tr/cepptt/html.posta/gonderisorgu"

Kodları bu adresten veri alacak şekilde düzenledim.  İstenirse toplu sorgulama da yapılabilir tabii ki, ama elimde birden fazla barkod numarası olmadığı için örnek veremiyorum. Bilenler bilir, sadece sorguyu döngü içinde almak gerek. 

Faydalı olması dileğiyle. --)(

■ [b]Gerekli kodlar bunlardır;[/b]

Private Declare Function InternetCheckConnection Lib "wininet.dll" _
    Alias 
"InternetCheckConnectionA" (ByVal lpszUrl As String, _
    ByVal dwFlags As Long
, ByVal dwReserved As Long) As Long
Private Declare Function apiShowWindow Lib 
"user32" Alias _
    
"ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Sub CommandButton1_Click
()
    Dim URL As String, IE As Object, docX As Object
    Dim i As Integer
, c As Integer, j As Integer
    Application
.ScreenUpdating = False
    Range
("A2:B13").ClearContents
    Range
("A2:C" & Range("C65536").End(3).Row).Interior.ColorIndex = 0
    Range
("A10:D1000").ClearContents
    URL 
= "https://wap.ptt.gov.tr/cepptt/html.posta/gonderisorgu"
    If (InternetCheckConnection(URL & "/", &H1, 0&) = 0) Then MsgBox "internet bağlantısı yok": Exit Sub
    Set IE 
= CreateObject("InternetExplorer.Application")
    With IE
        
.Navigate URL
        
.Visible = True
        apiShowWindow IE
.hwnd, 2
    Do While IE
.Busy: DoEvents: Loop
    Do Until IE
.ReadyState = 4: DoEvents: Loop
        
.Document.all.barkod.Value = Range("H2").Value
        
.Document.forms(0).submit
    Do While IE
.Busy: DoEvents: Loop
    Do Until IE
.ReadyState = 4: DoEvents: Loop
    On Error Resume Next
    For i 
= 0 To 4
        If InStr
(1, .Document.getelementsbytagname("TABLE")(i).innertext, "Barkod", vbTextCompare) > 0 Then
            Set docX 
= .Document.getelementsbytagname("TABLE")(i)
            c = 1
            For Each tr In docX
.all.tags("TR")
                c = c + 1
                For j 
= 0 To tr.all.tags("TD").Length - 1
                    Cells
(c, j + 1) = tr.all.tags("TD").Item(j).innertext
                Next j
            Next tr
        End If
    Next i
    End With
    Rows
("14").Delete
    Range
("A15:C" & Range("C65536").End(3).Row).Style = "İyi"
    Range("A2:C13").Style = "Nötr"
    Columns.AutoFit:
    IE.Quit
    Application
.ScreenUpdating = True
    Set IE 
= Nothing: Set docX = Nothing: URL = "": i = Empty: c = Empty: j = Empty
End Sub

Hoşça kalın !  

 
Gönderildi : 26/11/2013 15:44

Paylaş: