Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel [VBA]如何检查是否可以访问internet磁盘_Excel_Vba - Fatal编程技术网

Excel [VBA]如何检查是否可以访问internet磁盘

Excel [VBA]如何检查是否可以访问internet磁盘,excel,vba,Excel,Vba,要使用密码和ID访问internet磁盘,我有一个访问as和下面的代码 Set wsh= WScript.CreateObject("WScript.Shell") returnvalue = wsh.run("net use address /ID password",0,true) 但有时当互联网速度较慢或密码更改时,wsh不会响应,代码只是挂起 returnvalue = wsh.run("net use address /ID password",0,true) 考虑到在一段等待时间

要使用密码和ID访问internet磁盘,我有一个访问as和下面的代码

Set wsh= WScript.CreateObject("WScript.Shell")
returnvalue = wsh.run("net use address /ID password",0,true)
但有时当互联网速度较慢或密码更改时,wsh不会响应,代码只是挂起

returnvalue = wsh.run("net use address /ID password",0,true)

考虑到在一段等待时间结束后通过该行并转到下一行可以防止挂起,但我不知道是否存在这样的API/语法。

最好的方法是通过一个WNetAddConnection API()或WScript.Network的MapNetworkDrive方法。两者都将使用合理的超时并报告错误。