Check if mapped network available

前端 未结 3 1847
独厮守ぢ
独厮守ぢ 2021-01-28 17:03

I am trying to have my program check is a mapped network drive is actually connected, and change the curDrive variable based on the result. It works okay, but if the drive is st

3条回答
  •  误落风尘
    2021-01-28 17:23

    There is no long delay when testing for a drive letter using the FileSystemObject and DriveExists:

    Sub Tester()
    
        Dim n As Integer
    
        For n = 1 To 26
            Debug.Print Chr(64 + n), HaveDrive(Chr(64 + n))
        Next n
    
    End Sub
    
    
    
    Function HaveDrive(driveletter)
        HaveDrive = CreateObject("scripting.filesystemobject").driveexists(driveletter)
    End Function
    

提交回复
热议问题