How can I set up Excel to check if the computer is connected to the internet?

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

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s