Results 1 to 2 of 2

Google Maps API

Threaded View

  1. #1
    Registered User
    Join Date
    11-20-2017
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    1

    Google Maps API

    i am trying to find the distance and travel time between multiple origins and destinations. For some reason, my code does not work at all. There are no errors, i just have nothing as output. the problem is that activex can not create an object.

    The code is as follows:

    #########
    Sub Origins_Destinations()
    Dim a, b, i, Str As String
    Dim lineS As Variant

    'On Error Resume Next
    'Application.ScreenUpdating = False

    With CreateObject("WinHttp.WinHttpRequest")
    Dim iRow As Long: iRow = ThisWorkbook.Worksheets(1).Range("g65000").End(xlUp).Row
    For j = 4 To iRow
    b = ThisWorkbook.Worksheets(1).Range("b4" & j)
    a = ThisWorkbook.Worksheets(1).Range("a4" & j)
    .Open "GET", "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=" & a & " &destinations= " & b & " &key=MY_KEY", False
    .Send
    lineS = Split(.ResponseText, vbLf)
    For k = 25 To UBound(lineS)
    If Trim(lineS(k)) = """distance"" : {" Then
    Exit For
    End If
    Next k
    ThisWorkbook.Worksheets(1).Range("c" & j) = lineS(k + 1)
    ThisWorkbook.Worksheets(1).Range("d" & j) = lineS(k + 5)
    Application.Wait (Now + TimeValue("0:00:01"))
    Next j
    End With
    Application.ScreenUpdating = True
    End Sub
    #########

    Any suggestions ??
    Last edited by Gamal; 11-20-2017 at 02:25 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Route Calculator - Google Maps Api 22 Minutes quicker than Actual Google Website
    By lookingforhelp1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-06-2015, 01:23 PM
  2. Macro with google maps
    By billyshears in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2013, 11:54 AM
  3. hyperlink for google maps
    By tlynchjr@aol.com in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-06-2013, 05:48 PM
  4. Google Maps Info
    By kocheleknick in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-26-2012, 10:53 AM
  5. Google Maps integration
    By GeorgY in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2011, 10:51 PM
  6. Google Maps in Excel?
    By kklein in forum Excel General
    Replies: 8
    Last Post: 09-26-2011, 06:54 PM
  7. Google maps in excel
    By censura in forum Excel General
    Replies: 0
    Last Post: 02-21-2008, 04:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1