Avez vous une idée sur comment je peux tester qu'une conexion internet
active est disponible en Vba ??
(Valable aussi bien pour le modem 56K ou Adsl ou via Réseau ?)
J'ai trouvé cette fonction :
qui marche bien lors d'une conexion, mais des lors qu'il n'y en a pas Excel
plante.
Public Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As
Long, ByVal dwReserved As Long) As Long
'se connecte
Function testInternet()
Dim lResult As Long
lResult = InternetAutodial(1, 0&) 'Retourn 1 si testOK
MsgBox lResult
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Shewy80
j'ai trouvé une solution sur le net
je vous la soumet : elle semble bien fonctionner, si vous pouviez la tester de votre coté et me dire si Ok ou pas ?
Public Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _ (lpdwFlags As Long, _ ByVal lpszConnectionName As String, _ ByVal dwNameLen As Long, _ ByVal dwReserved As Long) As Boolean
Function getConnectionName() Dim lpdwFlags As Long Dim lpszConnectionName As String Dim dwNameLen As Long Dim dwReserved As Long Dim endOfString As Long dwNameLen = 256 lpszConnectionName = Space(dwNameLen) dwReserved = 0
getConnectionName = "" If InternetGetConnectedStateEx(lpdwFlags, lpszConnectionName, dwNameLen, dwReserved) Then endOfString = InStr(1, lpszConnectionName, Chr(0)) If endOfString > 0 Then getConnectionName = Left(lpszConnectionName, endOfString - 1) End If
If getConnectionName = "" Then MsgBox "Pas de conexion active" Else MsgBox getConnectionName End If End Function
source : http://forum.rue-montgallet.com/ruemontgallet/Programmation/-VB-Connection-internet-active-sujet-19797-1.htm de paxcal
j'ai trouvé une solution sur le net
je vous la soumet :
elle semble bien fonctionner, si vous pouviez la tester de votre coté et me
dire si Ok ou pas ?
Public Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
(lpdwFlags As Long, _
ByVal lpszConnectionName As String, _
ByVal dwNameLen As Long, _
ByVal dwReserved As Long) As Boolean
Function getConnectionName()
Dim lpdwFlags As Long
Dim lpszConnectionName As String
Dim dwNameLen As Long
Dim dwReserved As Long
Dim endOfString As Long
dwNameLen = 256
lpszConnectionName = Space(dwNameLen)
dwReserved = 0
getConnectionName = ""
If InternetGetConnectedStateEx(lpdwFlags, lpszConnectionName, dwNameLen,
dwReserved) Then
endOfString = InStr(1, lpszConnectionName, Chr(0))
If endOfString > 0 Then getConnectionName = Left(lpszConnectionName,
endOfString - 1)
End If
If getConnectionName = "" Then
MsgBox "Pas de conexion active"
Else
MsgBox getConnectionName
End If
End Function
source :
http://forum.rue-montgallet.com/ruemontgallet/Programmation/-VB-Connection-internet-active-sujet-19797-1.htm
de paxcal
je vous la soumet : elle semble bien fonctionner, si vous pouviez la tester de votre coté et me dire si Ok ou pas ?
Public Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _ (lpdwFlags As Long, _ ByVal lpszConnectionName As String, _ ByVal dwNameLen As Long, _ ByVal dwReserved As Long) As Boolean
Function getConnectionName() Dim lpdwFlags As Long Dim lpszConnectionName As String Dim dwNameLen As Long Dim dwReserved As Long Dim endOfString As Long dwNameLen = 256 lpszConnectionName = Space(dwNameLen) dwReserved = 0
getConnectionName = "" If InternetGetConnectedStateEx(lpdwFlags, lpszConnectionName, dwNameLen, dwReserved) Then endOfString = InStr(1, lpszConnectionName, Chr(0)) If endOfString > 0 Then getConnectionName = Left(lpszConnectionName, endOfString - 1) End If
If getConnectionName = "" Then MsgBox "Pas de conexion active" Else MsgBox getConnectionName End If End Function
source : http://forum.rue-montgallet.com/ruemontgallet/Programmation/-VB-Connection-internet-active-sujet-19797-1.htm de paxcal