Home > Enterprise >  Need advice with Error Handling for Invalid Path
Need advice with Error Handling for Invalid Path

Time:01-26

I could use some advice on how to handle a strange issue that happens to my users.

Issue: All of my users are on laptops that use VPN to connect to our network. When they disconnect from the VPN and reconnect the network drive also disconnects till they open the drive or folder through file explorer. When this happens and they don't re-establish the connection to the network drive they end up with 3304 error.

Error Handling? What I'd like to do is setup some sort of error handler to tell them thats what happened with a potential link they could click on to re establish the connection. OR even better just have the VBA code identify that error 3304 has occurred and re-establish the connection automatically for them and no pop up error happen at all.

Has anyone done this? I've done some research but nothing I've found quite fits the criteria for this issue. Looking for any advice or push in the right direction.

I was thinking of something like this where either they get a pop up with a link or skip the pop up all together and find a way to re-connect the drive in the background.

On Error GoTo ErrHandler

'Error Handler
ErrHandler:
If Err.Number = 3304 Then

MsgBox "Error Number:" & Err.Number & vbCrLf & _
    "Error Description: " & Err.Description & vbCrLf & _
    "This error is due to your VPN being disconnected and reconnected"
Else
End If 

CodePudding user response:

We faced that issue a couple months ago. We took the route of actually just showing an informative MsgBox to tell the users what to do to solve by themselves calling a function into the 'Workbook_Open' event that fails if a Central Code for the Company its not found with the Dir() function:

Function IsVPNOn(ByVal strCentralCodePath As String) As Boolean
Dim retBoolean As Boolean
On Error Resume Next

If IsError(Dir(strCentralCodePath & g_strCentralCodeName)) Then
    MsgBox "The VPN seems to be disconnected." & vbCr & vbCr & _
           "Please check VPN connection if Company toolbar is needed.", _
            vbCritical   vbOKOnly, "Company Ribbon"
    retBoolean = False
Else
    retBoolean = True
End If

IsVPNOn = retBoolean
End Function

Not gonna lie, the second option with skipping and reconnecting without the user being even aware of the problem seems more classy, but it is way trickier as you have to deal with connections inside your code.

CodePudding user response:

Run DOS command "net use : \ComputerName\ShareName /PERSISTENT:YES" if error comes up. how to do this: How do I enter a net use string into CMD using the VBA Shell command?

  • Related