Dim mydoc As MSHTML.HTMLDocument
Dim virginbrowser As Boolean
Dim NAVcounter As Integer
Dim po_Lat As Single
Dim po_Long As Single
Dim po_Alt As Single
Dim ge_Speed As String
Dim conID As String
Dim GE_flight_rs As DAO.Recordset
Dim GE_flight_ok_move_next As Boolean
Private Sub btn_fly_contracts_Click()
Call GE_next_flight_point
End Sub
Private Sub form_load()
On Error GoTo err_handler
virginbrowser = True 'set this to stop the first couple of navigations that take place
NAVcounter = 1 'this counts the navigates before we want to trap the navigates
'*****************NEED TO CHANGE THIS to the path of the html page****
Me.WebBrowser4.Navigate CurrentProject.path & "\trial.html"
Set mydoc = Me.WebBrowser4.Document
'form_load:
Exit Sub:
err_handler:
MsgBox _
"An unexpected error has been detected" & Chr(13) & _
"Description is: " & Err.Number & " , " & Err.Description & Chr(13) & _
"Please note the above details before contacting support"
'Resume form_load
End Sub
Private Sub GE_next_flight_point()
On Error GoTo Err_GE_next_flight_point
ge_Speed = 1
ge_Speed = Replace(ge_Speed, ",", ".")
po_Alt = 10000
po_Lat = Forms![Main]![Lat]
po_Long = Forms![Main]![Long]
Call mydoc.parentWindow.execScript("pointtour('" & po_Lat & "','" & po_Long & "','" & po_Alt & "'," & _
ge_Speed & ")", "Jscript")
Exit_GE_next_flight_point:
Exit Sub
Err_GE_next_flight_point:
MsgBox Err.Description
Resume Exit_GE_next_flight_point
End Sub
Private Sub WebBrowser4_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
On Error GoTo Err_WebBrowser4_BeforeNavigate2
NAVcounter = NAVcounter + 1
Debug.Print NAVcounter
'when I test this there are 3 navigates to get GE started. So from 4 onwards we need to capture it.
If NAVcounter > 4 Then
Dim strfrombrowser As String
Cancel = True ' always need this
Debug.Print "Full URL" + URL
'get just my information
strfrombrowser = Right(URL, (Len(URL) - InStrRev(URL, "\")))
'this is just the code
Debug.Print "Before Navigate left 2 URL - " & Left(strfrombrowser, 2)
Select Case Left(strfrombrowser, 2)
Case "03"
GE_flight_ok_move_next = True
Debug.Print "In select Called"
Call GE_next_flight_point
End Select
End If
Exit_WebBrowser4_BeforeNavigate2:
Exit Sub
Err_WebBrowser4_BeforeNavigate2:
MsgBox Err.Description
Resume Exit_WebBrowser4_BeforeNavigate2
End Sub