I am creating an operating system and there will be updates. I want VBA to check if there is an active Internet connection through WiFi or Ethernet. If the check is successful, then it sends you to a certain slide, but if it failed, then it sends you to another slide
This is the code I tried and it's not working:
Private Function IsInternetConnected(Optional SupressMessage As Boolean) As Boolean
Dim objHTTP As Object
'Test for Internet Connection
If IsInternetConnected = True Then
ActivePresentation.SlideShowWindow.View.GotoSlide 3
End
'Report to User if Internet Connection not detected
If IsInternetConnected = False And SupressMessage = False Then
ActivePresentation.SlideShowWindow.View.GotoSlide 2
End If
End Function
I managed to make the code work. The only thing I had to do, not specified anywhere, was to add a shape to which I assigned the action that would start the macro. Here is the code:
Sub InternetCheck()
Dim objSlide As Slide
Dim objShape As Shape
Dim strURL As String
Dim blnConnected As Boolean
strURL = "http://www.bing.com"
On Error Resume Next
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.Open "GET", strURL, False
objXMLHTTP.Send
If objXMLHTTP.Status = 200 Then
blnConnected = True
Else
blnConnected = False
End If
On Error GoTo 0
If blnConnected Then
ActivePresentation.SlideShowWindow.View.GotoSlide (3)
Else
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
End If
End Sub
To start the code, it must be automated with a module that calls the macro.