
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
VBA check if folder exists
Hi, Community.
I found way to check in VBA if folder exists on PC, but it works only in Excel VBA:
sub Check
If Dir("C:\My Documents\") <> "" Then
MsgBox "Yes, path exists"
Else
MsgBox "No, path does not exist."
End If
end sub
Is there any way to check this stuff in QlikView macro?
Thanks.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since macros in QlikView is using VBScript (or JScript) you don't have the Visual Basic for Applications function called Dir.
An alternative is to use the FileSystemObject in Windows like this:
Set fso = CreateObject("Scripting.FileSystemObject")
foldername = "C:\Program Files (x86)"
On Error Resume Next
Set f = fso.GetFolder(foldername)
On Error Goto 0
MsgBox "The folder [" & foldername & "] do " & Left("NOT",(Len(f)=0)*-3) & " exist"
You have to turn off error messages before the GetFolder function call as it throws an error if not.
Line #3 turns errors off and line #5 turns them on again (as you probably know ... )

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since macros in QlikView is using VBScript (or JScript) you don't have the Visual Basic for Applications function called Dir.
An alternative is to use the FileSystemObject in Windows like this:
Set fso = CreateObject("Scripting.FileSystemObject")
foldername = "C:\Program Files (x86)"
On Error Resume Next
Set f = fso.GetFolder(foldername)
On Error Goto 0
MsgBox "The folder [" & foldername & "] do " & Left("NOT",(Len(f)=0)*-3) & " exist"
You have to turn off error messages before the GetFolder function call as it throws an error if not.
Line #3 turns errors off and line #5 turns them on again (as you probably know ... )

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wonderful!
Thanks.
