Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
amien
Specialist
Specialist

file select dialog needed

what i want is a button. behind that button should be a file chooser dialog. After the file is selected a variable is filled with the selected filename including the path of the file. Is this possible?

1 Solution

Accepted Solutions
Not applicable

Hey Amien,

One approach is to add an Action to the button that triggers a macro. In the button properties, select the "Action" tab and click the "Add" button. Choose "External" as the Action Type, and "Run Macro" as the Action. After clicking OK, you will see a text box for Macro Name and a button that says "Edit Module". The Macro Name must be the name of one of the subroutines in your Macro module. Clicking on the Edit module button will bring up the Module editor. You have an option of writing your macro in VBScript or JScript. The rest of what I say assumes you are using VBScript.

Assuming you have the right DLLs/OCXs installed, the following subroutine should open a file chooser dialog and set the result to a variable called "Variable1":

Sub ChooseFile
' Create the dialog

set cd = CreateObject("UserAccounts.CommonDialog")
'Display it to the user
result = cd.ShowOpen
dim filePath
if(result <> 0)
'Assign the result to the filePath variable
filePath = cd.FileName
end if
' Get the QlikView variable
set v = ActiveDocument.Variables("Variable1")
' Assign the value
v.SetContent filePath, true
End Sub

View solution in original post

5 Replies
Not applicable

Hey Amien,

One approach is to add an Action to the button that triggers a macro. In the button properties, select the "Action" tab and click the "Add" button. Choose "External" as the Action Type, and "Run Macro" as the Action. After clicking OK, you will see a text box for Macro Name and a button that says "Edit Module". The Macro Name must be the name of one of the subroutines in your Macro module. Clicking on the Edit module button will bring up the Module editor. You have an option of writing your macro in VBScript or JScript. The rest of what I say assumes you are using VBScript.

Assuming you have the right DLLs/OCXs installed, the following subroutine should open a file chooser dialog and set the result to a variable called "Variable1":

Sub ChooseFile
' Create the dialog

set cd = CreateObject("UserAccounts.CommonDialog")
'Display it to the user
result = cd.ShowOpen
dim filePath
if(result <> 0)
'Assign the result to the filePath variable
filePath = cd.FileName
end if
' Get the QlikView variable
set v = ActiveDocument.Variables("Variable1")
' Assign the value
v.SetContent filePath, true
End Sub

Not applicable

For a more complete discussion of the topic, as well as the specific limitations of the approach already mentioned here, please see this thread:

http://community.qlik.com/forums/p/23565/90250.aspx

amien
Specialist
Specialist
Author

Thanks

http://community.qlik.com/forums/t/23565.aspx

Not applicable

Hi Simon,

i am trying to work on "open/save dialog box" , but not able to get correct solution.

I seen your code but having an doubt how to provide the right DLLs/OCXs installed.

Pls any suggestion regarding this.

Regards

Venkat

Not applicable

This is a workaround using PowerShell for all having problems in 64-bit environments.

Cheers