I found this function on a web
Private Function FileFolderExists(strFullPath As String) As Boolean
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString then
FileFolderExists = True
End If
EarlyExit:
On Error GoTo 0
End Function
And I want to pass string variable like this
Dim lineText As String
...
ElseIf FileFolderExists(lineText) = False Then
I am getting compile error “byref argument type mismatch”
When I put byval before strFullPath, it doesn’t seem to work properly.
I also tried playing with Dir function, it works if I pass literal like “C:\test”, but it doesn’t work if I pass the variable.
Does anyone have function that check for folder existence and accepts the string variable as parameter ?
Thanks in advance
The problem seems to be that Word adds CR character to every paragraph, or, to be more exact, that the
Textproperty of theParagraphobject returns the paragraph text plus the CR character.AFAIK, this is the Word’s behaviour for every paragraph, even for the last one.
How can this cause a compile error, I do not have a clue. If I take Milan’s example:
it returns
true,trueif the first line of the document is a valid folder. If I comment the marked line, the program still compiles and runs and returnstrue,false(with the same document).There is some info about it on MSDN website