Voici un code simple pour vérifier l'état de la connexion à internet.
Private Declare Function IsNetworkAlive Lib "SENSAPI.DLL" _
(ByRef lpdwFlags As Long) As Long
Sub verificationConnection()
Select Case IsNetworkAlive(0)
Case 0: MsgBox "not connected"
Case 1: MsgBox "connected to LAN"
Case 2: MsgBox "connected to WAN"
Case Else: MsgBox "connected to other network"
End Select
ThisWorkbook.FollowHyperlink "http://www.wanao.com", , True
End Sub
<note>Source</note>