title: How to use appIE.Document.Body.innerHTML
body: <p>So I'm trying to retrieve the latitude and longitude of a given postal code, and am trying to use VBA to place this into an excel worksheet. My code is as follows:</p>
  
  <pre><code>Private appIE As Object
  
  Function GeoCode(sLocationData As String) As String
  '//Dont want to open and close all day long - make once use many
  If appIE Is Nothing Then
      CreateIEApp
      '// Creates a new IE App
      '// if = nothing now then there was an error
      If appIE Is Nothing Then
          GeoCode = "Sorry could not launch IE"
          Exit Function
      Else
          '// do nothing
      End If
  Else
      '// do nothing
  End If
  '//clearing up input data
  'sLocationData = Replace(sLocationData, ",", " ")
  sLocationData = Replace(sLocationData, " ", "+")
  sLocationData = Trim(sLocationData)
  
  '//Build URL for Query
  sLocationData = "http://maps.google.com/maps/geo?q=%20_" &amp; sLocationData
  
  '// go to the google web service and get the raw CSV data
  '// CAUSES PROBLEM AS SPECIFIED BELOW
  appIE.Navigate sLocationData
  
  Do While appIE.Busy
      Application.StatusBar = "Contacting Google Maps API..."
  Loop
  
  Application.StatusBar = False
  On Error Resume Next
  
  '// Parsing
  GeoCode = appIE.Document.Body.innerHTML
  GeoCode = Mid(GeoCode, InStr(GeoCode, ",") + 1, InStr(GeoCode, "/") - InStr(GeoCode, ",") - 2)
  
  appIE = Nothing
  End Function
  </code></pre>
  
  <p>The Google Maps API then returns a JSON formatted value, as per this link:</p>
  
  <p><a href="http://maps.google.com/maps/geo?q=%20_400012" rel="nofollow">http://maps.google.com/maps/geo?q=%20_400012</a></p>
  
  <p>I then attempt to retrieve this value using<br>
  <code>appIE.Document.Body.innerHTML</code>,<br>
   and parsing that value for the data I want. However, the moment the code hits   <code>appIE.Navigate sLocationData</code>,<br>
  I'm prompted to save a file called "geo". When saved and opened as a .txt file, I get the exact same JSON formatted value, but I need the values within my worksheet itself.</p>
  
  <p>Is there a way to do this?</p>
  
  <p>Thanks in advance!</p>