|

楼主 |
发表于 2014-12-27 08:36
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
2.文件夹有关的操作
2.1判断文件夹是否存在
FolderExists方法可以判断指定的文件夹是否存在,若存在则返回True。其语法为:
fso.FolderExists(FolderSpec)
参数FolderSpec指定文件夹的完整路径,String类型,不能包含通配符。
如果用户有充分的权限,FolderSpec可以是网络路径或共享名,例如:
If fso.FileExists ("\\NTSERV1\d$\TestPath\") Then
示例如下:
Sub 按钮1_Click()
Application.ScreenUpdating = False
Set fso = CreateObject("Scripting.FileSystemObject")
strfile = Application.InputBox("请输入文件的完整名称:", "请输入文件的完整名称:", , , , , , 2)
If fso.fileexists(strfile) Then
MsgBox strfile & " :存在"
Else
MsgBox strfile & " :不存在"
End If
Application.ScreenUpdating = True
End Sub
|
|