Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How can I remap a Letter to a network drive in VBA if it becomes disconnected?

I have an application launcher that checks the server for a newer version of the application before opening the users' local copy. It has an error trap that successfully traps a 3044 error like this:

Err_OpenApp:

Select Case Err.Number

Case 3044

    Msgbox "Network is not accessible - Opening your current copy" ...

Case Else
     Msgbox Err.Number & " - " & Err.Description
End Select 

What I would like to do is replace this trap with

... case 3044

Msgbox "S drive has become disconnected.  Attempting to remap to S", "Can't find your S Drive"


Dim oNetwork As Object
Dim sDrive As String
Dim sPath As String


Set oNetwork = CreateObject("WScriprt.Network")
sDrive = "S:"
sPath = "\\Server\Drive"

oNetwork.MapNetworkDrive sDrive, sPath

And if it still can't remap, finally add the following:

MsgBox "Network is not accessible - Opening your current copy"

But I get a run-time error 429: ActiveX Component. Can't create Object

Is there a way around this?

Comments