Hola ,
Prueba con el siguiente código y adaptalo según tus necesidades
Poner en un MODULO standard Option Explicit
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Function funTest()
Rem Localiza 1 direccion If funGoogleMaps("Puerta del sol 1", "Madrid", "", "Spain") = False Then MsgBox "Error No ha sido posible visualizar el mapa", vbExclamation, "Google Maps" End If
Rem localiza 1 ciudad If funGoogleMaps("", "Madrid", "", "Spain") = False Then MsgBox "Error No ha sido posible visualizar el mapa", vbExclamation, "Google Maps" End If
Rem Localiza 1 pais If funGoogleMaps("", "", "", "Spain") = False Then MsgBox "Error No ha sido posible visualizar el mapa", vbExclamation, "Google Maps" End If
End Function
Public Function funGoogleMaps(PonDireccion As Variant, PonCiudad As Variant, PonCodigoPostal As Variant, PonPais As Variant) As Boolean Dim strURL As String Dim objIE As Object
On Error GoTo Err_Local Access.Application.DoCmd.Hourglass True
If funConexionInternetGoogle = False Then MsgBox "Tu PC No esta conectado a Internet" & vbNewLine & _ "Deberias conectarlo para continuar", vbExclamation, "Conexion Internet" GoTo Exit_Local End If
strURL = "http://maps.google.com/maps?f=q&hl=en&q=" & PonDireccion & "+" & PonCiudad & "+" & PonCodigoPostal & "+" & PonPais
Set objIE = CreateObject("InternetExplorer.Application") objIE.Navigate strURL objIE.Visible = True
DoCmd.Minimize ' << Opcional Application.DoCmd.RunCommand acCmdAppMinimize ' << Opcional
Close_Local: Set objIE = Nothing funGoogleMaps = True
Exit_Local: Access.Application.DoCmd.Hourglass False Exit Function
Err_Local: funGoogleMaps = False MsgBox Err.Description, vbCritical, "Error N°: " & Err.Number
Resume Exit_Local
End Function
Public Function funConexionInternetGoogle() As Boolean On Error GoTo Err_Local
Const cUrl = "http://www.google.com/"
DoEvents funConexionInternetGoogle = InternetCheckConnection(cUrl, &H1, 0&)
If funConexionInternetGoogle = False Then funConexionInternetGoogle = False Else funConexionInternetGoogle = True End If
Exit_Local: Exit Function
Err_Local: MsgBox Err.Description, vbCritical, Err.Number Resume Exit_Local
End Function
------------- https://www.accessdemo.info" rel="nofollow - https://www.accessdemo.info
|