2013-02-14 33 views

回答

2

你有引号

什么代码基本上是试图做的是检查相关文件,目录或文件夹之间存在的不必要的空间。看看这个例子,它检查文件是否存在。

Option Explicit 

Sub Sample() 
    Dim sPath As String 

    sPath = "C:\Temp\MyFile.xls" 

    If Dir(sPath) = "" Then 
     MsgBox "File not found" 
    Else 
     MsgBox "File found" 
    End If 
End Sub 

更多关于DIRhere

+0

谢谢。但是sPath =“”会做什么? – 2013-02-14 07:13:30

+2

我猜你给的代码是更大代码的一部分。我所假设的是,如果没有找到某个特定的文件或目录,那么它将'path'变量重置为空。 – 2013-02-14 07:16:29

+0

方面评论:我使用'folderExists =((GetAttr(parPath)和vbDirectory)= vbDirectory)'而不是... – assylias 2013-02-14 07:17:34