Test if Internet connection is available or not



Purpose: test if Internet connection is available or not

Use the following function to test whether an Internet connection is available on the end user’s computer:

Public Function IsInternetAvailable()

Dim XLSPadlock As Object

On Error GoTo Err

Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object

If XLSPadlock.PLEvalVar("InternetConnected") = "1" Then

 IsInternetAvailable = True


 IsInternetAvailable = False

End If

Exit Function


IsInternetAvailable = False

End Function


You can then call the function. For instance, the following code sets the value of a cell:

Private Sub Workbook_Open()

If IsInternetAvailable Then

Sheet1.Range("S24") = "Internet Available"


Sheet1.Range("S24") = "No Internet"

End If

End Sub


Copyright © 2023 G.D.G. Software