-
get value from local html file
I have built a little app that I use to add POI into an access database.
It dynamicall generates a html page (stored locally) that contains the google map and displays the page in a browser on the user form.
The page contains a map and two input elements, one for Latitude and one for longitude
Th map is shown using this:
[vba]Private Sub show_map()
Dim url As String
Dim objBrowser As Object
Dim lt As String
url = ThisWorkbook.path & "/results.htm"
Set objBrowser = Me.WB1
With Me.WB1
.navigate url
If .readystate = 4 Then
DoEvents
End If
End With
End Sub[/vba]
What I want to do is get the lat & Lon values from this page and pass them to the user form.
I have tried the following [vba]Function get_lat_lon()
Dim lat As String
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate ThisWorkbook.path & "\results.htm"
While ie.Busy
DoEvents
Wend
Application.Wait Now + TimeSerial(0, 0, 1) 'Pause 1 second
lat = ie.document.getElementById("lat").innerText
MsgBox (lat)
ie.Quit
End Function[/vba]
But when it runs I get an error message :
"The object invoked has disconnected from its clients"
If I change the url to a 'proper' web page this function works so I am assuming the problem is because the file I am accessing is a local file.
Any help greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules