Share via

Watchdog Timer VBA Excel

Anonymous
2023-02-08T08:29:40+00:00

Dear Sir,

When we integrate Excel with Third Party Application for data Transfer and when internet communication breaks, is there any alarm or Watchdog timer, that we can configure in this ?

Especially Watchdog Timer for VBA Excel which will alarm the user for possible internet connection break and ask user to not conisder sent datapoints as they will be wrong .

Please confirm

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

8 answers

Sort by: Most helpful
  1. Anonymous
    2023-02-08T10:40:20+00:00

    Here is a sample macro for checking the internet connection status in VBA:

    Sub CheckInternetConnection()

    Dim objHTTP As Object

    Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

    On Error Resume Next

    objHTTP.Open "GET", "https://www.google.com", False objHTTP.Send

    If objHTTP.Status = 200 Then MsgBox "Internet connection is active.", vbInformation, "Connection Status" Else MsgBox "Internet connection is not active. Please check your connection.", vbCritical, "Connection Status" End If

    End Sub

    You can call this function from another procedure to check the internet connection status.

    Here is an example:

    Sub TestInternetConnection()

    If CheckInternetConnection = False Then 'Internet connection is not active MsgBox "Internet connection is not active. Please check your connection.", vbCritical, "Connection Status" Else 'Internet connection is active MsgBox "Internet connection is active.", vbInformation, "Connection Status" End If

    End Sub

    In this example, the TestInternetConnection procedure calls the CheckInternetConnection function and displays a message to the user based on the result.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-02-08T10:35:49+00:00

    Dear Sir,

    Can you please write sample macro about how to handle this in VBA and share it with me and like function call in Sub procedure withe example of this ?

    Will be grateful if you share the example for this ?

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2023-02-09T05:38:11+00:00

    Dear Sir,

    Really thanks for this actually.

    I want to know if above code checks the internet connection strength as well?

    It will only ping to Google.com and checks if it opens right?

    Also,

    Thanks.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2023-02-08T09:11:07+00:00

    Hi

    I'm AnnaThomas and I'd be happy to help you with your question. In this Forum, we are Microsoft consumers just like yourself.

    Unfortunately, VBA in Excel does not have a built-in Watchdog Timer for detecting internet connection issues. However, you can write a custom function in VBA to check the status of your internet connection and prompt the user if there is a break in communication.

    You can use the WinHttpRequest object in VBA to send a request to a known website and check the status code returned. If the status code indicates a connection error, you can display a message to the user.

    I hope this helps ;-), let me know if this is contrary to what you need, I would still be helpful to answer more of your questions.

    Best Regards,

    AnnaThomas

    Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2023-02-08T09:07:42+00:00

    Wow I didnt know we can integrate 3rd party software to transfer data.

    I've been wanting to do it.

    Please how....

    Was this answer helpful?

    0 comments No comments