Boostez vos compétences Excel avec notre communauté !
Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !
Option Explicit
Private Const NETWORK_ALIVE_LAN = &H1 'net card connection
Private Const NETWORK_ALIVE_WAN = &H2 'RAS connection
Private Const NETWORK_ALIVE_AOL = &H4 'AOL
Private Declare Function IsNetworkAlive Lib "Sensapi" _
(lpdwFlags As Long) As Long
Private Function IsNetConnectionAlive() As Boolean
Dim lngAlive As Long
IsNetConnectionAlive = IsNetworkAlive(lngAlive) = 1
End Function
Private Function IsNetConnectionLAN() As Boolean
Dim lngLAN As Long
If IsNetworkAlive(lngLAN) = 1 Then
IsNetConnectionLAN = lngLAN = NETWORK_ALIVE_LAN
End If
End Function
Private Function IsNetConnectionRAS() As Boolean
Dim lngRAS As Long
If IsNetworkAlive(lngRAS) = 1 Then
IsNetConnectionRAS = lngRAS = NETWORK_ALIVE_WAN
End If
End Function
Private Function IsNetConnectionAOL() As Boolean
Dim lngAOL As Long
If IsNetworkAlive(tmp) = 1 Then
IsNetConnectionAOL = lngAOL = NETWORK_ALIVE_AOL
End If
End Function
Private Function GetNetConnectionType() As String
Dim lngAlive As Long
If IsNetworkAlive(lngAlive) = 1 Then
Select Case lngAlive
Case NETWORK_ALIVE_LAN:
GetNetConnectionType = _
"Oui"
Case NETWORK_ALIVE_WAN:
GetNetConnectionType = _
"Oui"
Case NETWORK_ALIVE_AOL:
GetNetConnectionType = _
"Oui"
Case Else:
End Select
Else
GetNetConnectionType = _
"Non"
End If
End Function
Sub IsConnection()
Dim Internet As String
Internet = GetNetConnectionType
If Internet = "Non" Then
MsgBox "Pas d'internet Yann", vbOKOnly, "Pas de connection Internet" 'Tu n'auras qu'à remplacer cette ligne de colde
End If
End Sub
Option Explicit
Sub RECHERCHE_MAP()
Dim Depart, Arrivee
Depart = "56690 NOSTANG": Arrivee = "56000 VANNES"
Worksheets("Feuil1").Activate
'================================= ETABLISSEMENT D'UNE REQUETE SUR LE WEB =======================
With ActiveSheet.QueryTables.Add(Connection:="URL;http://maps.google.fr/maps?f=d&saddr=" _
& Depart & "&daddr=" & Arrivee, DESTINATION:=ActiveSheet.Range("A1"))
.Name = "itinéraire"
.BackgroundQuery = False
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
On Error GoTo Erreur_Connection
.Refresh BackgroundQuery:=False
End With
On Error Goto 0
Exit Sub
Erreur_Connection:
'L'action si on n'a pas de connection Internet ??
On Error Goto 0
End Sub
Option Explicit
Function Verifier_Connexion() As Integer
Dim x As ServerXMLHTTP
Dim strT As String
'************************************************************************************************************
'Tu dois activer la référence Miscrosoft XML, v6.0
'************************************************************************************************************
On Error Resume Next
Verifier_Connexion = False
Set x = New ServerXMLHTTP
x.Open "GET", "http://www.google.com"
x.setRequestHeader "Accept", "application/xml"
x.setRequestHeader "Content-Type", "application/xml"
x.Send strT
'Ici, en fonction de l'erreur, on va pouvoir déterminer s'il y a connexion ou pas.
If Err = 0 Then
Verifier_Connexion = True
Else
MsgBox "Pas de connexion Yann", vbOKOnly, "Erreur de connexion"
End If
On Error GoTo 0
End Function
Sub test()
Verifier_Connexion
End Sub
Sub REQUETE()
Dim qt As QueryTable
Worksheets("RECUP").Activate
Set qt = ActiveSheet.QueryTables.Add(Connection:="URL;http://google.fr", Destination:=ActiveSheet.Range("A1"))
With qt
.Name = "www.google.fr"
.BackgroundQuery = False
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.Refresh BackgroundQuery:=True
Do
DoEvents
Loop While qt.Refreshing = True
End With
UserForm1.CommandButton1.Visible = False
UserForm1.CommandButton2.Visible = True
End Sub
Pierrot; dommage que tu n'aies pas gardé en mémoire ce Fil dont tu parles.pas d'autre idée... mais il y avait un post relativement récent qui a fait couler beaucoup d'encre à ce sujet... peut être cette question y est traitée... A voir...
Do
DoEvents
Loop While qt.Refreshing = True
Si quelqu'un est intéressé par l'évolution de ma bidouille, je suis disposé à partager.
Sub REQUETE()
On Error GoTo suite
Worksheets("RECUP").Activate
With ActiveSheet.QueryTables.Add(Connection:="URL;http://google .fr", Destination:=ActiveSheet.Range("A1"))
.Name = "[URL="http://www.google.fr"]www.google.fr[/URL]"
.BackgroundQuery = False
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.Refresh BackgroundQuery:=True
Application.Wait Now + TimeValue("0:00:3")
End With
UserForm1.CommandButton1.Visible = False
UserForm1.CommandButton2.Visible = True
suite:
MsgBox ("problème de connexion ou de mauvaise définition de l'URL")
UserForm1.Hide
UserForm1.Show
End Sub
.Name = "[URL="http://www.google.fr"]www.google.fr[/URL]"
.Name = www.google.fr
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?
We use cookies and similar technologies for the following purposes:
Est ce que vous acceptez les cookies et ces technologies?