Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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.

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

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 ... )

View solution in original post

2 Replies
petter
Partner - Champion III
Partner - Champion III

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 ... )

Anonymous
Not applicable
Author

Wonderful!

Thanks.