• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Yol Mesafelerini Hesaplatmak ve Mapste Yolu Göstermek

  • Konbuyu başlatan Konbuyu başlatan ekoral
  • Başlangıç tarihi Başlangıç tarihi
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Katılım
21 Mart 2015
Mesajlar
20
Excel Vers. ve Dili
2013 türkçe
Arkadaşlar merhaba,

Vba de userform üzerinden 4 textbox ta 4 farklı şehir girilerek web browserdan yani google mapsten yol güzergahının gösterilmesi ve yol mesafesinin hesaplanması gerekiyor. Bunu yapmaya bilgim yeterli değil. Yardımınıza ihtiyacım var.

** ekte ki dosyada userformun olması gereken şeklini en basit şekilde oluşturdum.
** Resimde de userform webbrowserda görülmesi gerekeni gösterdim.
** Final notuma 20 puan ekleneceği için yapmam gerekiyor.

http://www.dosya.tc/server4/rdy739/userform_Resim.rar.html
 
Aşağıdaki kodu userformun kod bölümüne kopyalayıp deneyiniz.
Kod:
Private Sub CommandButton1_Click()

With WebBrowser1
    .Navigate "https://www.google.com.tr/maps/dir/" & TextBox1.Text & "/" & TextBox2.Text & "/" & TextBox3.Text & "/" & TextBox4.Text & "/"
    .Visible = True

    Do While Not .ReadyState = 4: DoEvents: Loop
    Do While .Busy: DoEvents: Loop
    
    Application.Wait Now + TimeValue("00:00:03")
    Set div = .Document.getElementsByTagName("div")
    For Each sınıf In div
        If sınıf.classname = "widget-pane-section-directions-trip-distance widget-pane-section-directions-trip-secondary-text" Then
            MsgBox Split(sınıf.innertext, ":")(2)
        End If
    Next
End With
End Sub


Private Sub UserForm_Initialize()
TextBox1.Text = "İzmir"
TextBox2.Text = "İstanbul"
TextBox3.Text = "Ankara"
TextBox4.Text = "Antalya"
End Sub

Ancak webbrowser google tarafından engellenebiliyor. Aşağıdaki kod ile de webbrowser kullanmadan Internet Explorer ile yapmak istediğini yapabilirsin.
Kod:
Sub Kod()

Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Navigate "https://www.google.com.tr/maps/dir/" & UserForm1.TextBox1.Text & "/" & UserForm1.TextBox2.Text & "/" & UserForm1.TextBox3.Text & "/" & UserForm1.TextBox4.Text & "/"
    .Visible = True

    Do While Not IE.ReadyState = 4: DoEvents: Loop
    Do While IE.Busy: DoEvents: Loop
    
    Application.Wait Now + TimeValue("00:00:03")
    Set div = .Document.getElementsByTagName("div")
    For Each sınıf In div
        If sınıf.classname = "widget-pane-section-directions-trip-distance widget-pane-section-directions-trip-secondary-text" Then
            MsgBox Split(sınıf.innertext, ":")(2)
        End If
    Next
End With
End Sub
 
Çok Teşekkür ederim :)
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Geri
Üst