Office中国论坛/Access中国论坛
标题:
如何检验C:\My Document\表1.xls是否存在?请教高手如何写VBA
[打印本页]
作者:
bfwz
时间:
2005-7-31 21:22
标题:
如何检验C:\My Document\表1.xls是否存在?请教高手如何写VBA
如何检验C:\My Document\表1.xls是否存在?请教高手如何写VBA
作者:
wanshan
时间:
2005-7-31 22:34
方法一:Function FileExists(filename As String) As Integer
Dim i As Integer
On Error Resume Next
i = Len(Dir$(filename))
If Err Or i = 0 Then FileExists = False Else FileExists = True
End Function
传入之参数是含完整路径之文件名称,若文件存在,则传回 -1,否则返回 0。
方法二:例:if dir("c:\windows\test.dll")="" then
msgbox "不存在"
end if
作者:
LucasLynn
时间:
2005-8-1 19:30
Set fs = CreateObject("Scripting.FileSystemObject")
if f.FileExists("C:\My Document\表1.xls") then
......
复制代码
End if
复制代码
[code][/code]
[此贴子已经被作者于2005-8-1 11:30:59编辑过]
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3