How can i check if a folder exists in mydocuments and if not it is created. This created an error:
Private Sub Command4_Click()
Dim BidFileDir As String
BidFileDir = Environ("UserProfile") & "\MyDocuments\BidFileBacku
ps"
CheckDirectory BidFileDir
End Sub
'if directory doesn't exist it's created
Public Function CheckDirectory(ByVal sDirectoryPath As String, Optional ByVal bCreateIfNotFound As Boolean = True) As Boolean
If LenB(Trim$(sDirectoryPath)
) > 0 Then
CheckDirectory = (LenB(Trim$(Dir$(sDirector
yPath, vbDirectory))) > 0)
If (Not CheckDirectory) And bCreateIfNotFound Then
MkDir sDirectoryPath
End If
End If
End Function
Don't want to use fso
Start Free Trial