This is an AWESOME question!

Sometimes when you design your excel application, you need it to be connected to the internet to support certain functions.

In order for that to work, it’s super important that your file checks to make sure the user is connected to the internet before it moves on to any other procedures in your app.

The below function will help you easily check to see if the user is connected to the internet so that your VBA knows exactly what the status is!

You’ll be able to use the below formula in any worksheet:

=ConnectionStatus()

In a new VBA module, add the below code:

Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef dwflags As Long, ByVal dwReserved As Long) As Long

Public Function ConnectionStatus() As Boolean

ConnectionStatus = InternetGetConnectedState(0&, 0&)

End Function
Advertisements