Webbrowser Control Refresh problem

terrix

New Member
Joined
Aug 8, 2011
Messages
2
Hi there!

hope someone can help me with this...

I have a macro that collects gps latitude and longitude and then opens a google maps static page:

Sheets("resume").WebBrowser1.Navigate ("http://maps.googleapis.com/maps/api/staticmap?center=" & Coord.Latitude & "," & Coord.Longitude & "&size=429x248&maptype=roadmap&zoom=12&sensor=false&markers=label:A|color:blue|38.693611,-9.338056&markers=label:B|color:blue|38.713056,-9.347777778&markers=label:X|size:mid|color:white|" & Coord.Latitude & "," & Coord.Longitude)

This is:

- Centering the map on current position
- Show 2 additional static markers
- Show a marker with current position

It is actually working but... I start the macro with a counter to repeat this operation 5 times, it only refreshes the map with current position in the end of the macro (last cycle). This way I will only get a map with the last coordinate, instead of refreshing the map with every new position...

start macro
cycle 1: no map refresh
cycle 2: no map refresh
cycle 3: no map refresh
cycle 4: no map refresh
cycle 5: map refresh ok
end of macro

I have tried:

Sheets("resume").WebBrowser1.Refresh
Sheets("resume").WebBrowser1.Refresh2

Nothing works :(

Thanks!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Can you supply some sample data? It's rather difficult to test your current macro without them.
 
Upvote 0
I'll try!

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub ImportData()
Dim ie_about As Object
Dim ie As Object
Dim Count As Integer
Dim Max As Integer
Dim IE_Version As String
Dim Coord As Coordinates

Application.ScreenUpdating = False
Sheets("Import").Select
Set ie = CreateObject("InternetExplorer.Application")

Set ie_about = CreateObject("InternetExplorer.Application")

ie_about.Visible = False
ie_about.Navigate "about:blank"

'wait for page to load
Do While ie.Busy And Not ie.readyState = 4:
Application.Wait (Now + TimeValue("0:00:02"))
DoEvents
Loop

ie_about.document.parentWindow.execScript "document.clear(); document.write(navigator.appVersion);"
'MsgBox Split(ie.document.DocumentElement.outerText, ";")(1)

IE_Version = Split(ie_about.document.DocumentElement.outerText, ";")(1)
ie_about.Quit
Set ie_about = Nothing
'MsgBox ("Using Browser: |" + IE_Version + "|")

Count = 0
Max = InputBox("Number of samples: ")
slp = InputBox("Samples reported every X seconds, 2 minimum recommended: ")
'Loop

With ie
.Visible = True
.Navigate "https://10.1.1.254/wmx-linkStatus.html?WWW_SID=AID95431&t=1305555467855" ' should work for any URL
For a_counter = 0 To Max

If Count = 0 Then
MsgBox ("Before clicking OK, make sure the new browser page is on Link Status page.")
End If

Do Until .readyState = 4: DoEvents: Loop

x = .document.body.innertext
x = Replace(x, Chr(10), Chr(13))
x = Split(x, Chr(13))
Range("A1").Resize(UBound(x)) = Application.Transpose(x)

On Error GoTo gpsHandler
Coord = getCoordenates

If IE_Version = " MSIE 8.0" Then
copycells_ie8
Else
copycells_ie9
End If

Sheets("resume").Select
Range("J1").Select
Selection.End(xlDown).Offset(1, 0).Value = Coord.Latitude '& Coord.Latitude_dir

Range("K1").Select
Selection.End(xlDown).Offset(1, 0).Value = Coord.Longitude '& Coord.Longitude_dir

Range("L1").Select
Selection.End(xlDown).Offset(1, 0).Value = Coord.Speed

Range("A1").Select

Coord.Latitude = Replace(Coord.Latitude, ",", ".")
Coord.Longitude = Replace(Coord.Longitude, ",", ".")

Sheets("resume").WebBrowser1.Navigate ("http://maps.googleapis.com/maps/api/staticmap?center=" & Coord.Latitude & "," & Coord.Longitude & "&size=429x248&maptype=roadmap&zoom=12&sensor=false&markers=label:A|color:blue|38.693611,-9.338056&markers=label:B|color:blue|38.713056,-9.386&markers=label:C|color:blue|38.707361,-9.430611&markers=label:D|color:blue|38.774778,-9.343&markers=label:E|color:blue|38.721156,-9.342989&markers=label:F|color:blue|38.799528,-9.333353&markers=label:G|color:blue|38.855303,-9.383914&markers=label:H|color:blue|38.724083,-9.435472&markers=label:I|color:blue|38.76925,-9.379694&markers=label:J|color:blue|38.702566,-9.418586&markers=label:K|color:blue|38.9682778,-9.4047774&markers=label:L|color:blue|38.787278,-9.313639&markers=label:M|color:blue|38.73747222,-9.39783333&markers=label:N|color:blue|38.79597222,-9.347777778&markers=label:X|size:mid|color:white|" & Coord.Latitude & "," & Coord.Longitude)

Sheets("Import").Select
Cells.Select
Selection.ClearContents
Selection.End(xlToLeft).Select
Selection.End(xlUp).Select
Sheets("Resume").Select

Application.ScreenUpdating = True

If Count > 10 Then
ActiveWindow.SmallScroll (1)
End If

Application.ScreenUpdating = False

Sheets("Import").Select
Count = Count + 1
Sleep slp * 1000

Next a_counter
End With
Sheets("Resume").Select

gpsHandler:
Coord.Course = ""
Coord.Date = ""
Coord.Latitude = "0"
Coord.Latitude_dir = ""
Coord.Longitude = "0"
Coord.Longitude_dir = ""
Coord.Speed = "0"
' MsgBox Err.Number & Err.Description

Resume Next

Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top