Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set a Document Variable with vbscript macro

Hi Everyone,

I want to set three variables uid, username and pwd in my qv document.

User click on a button, then a macro is called and asks for User name and password.

When user enters these two things, then macro should extract uid from database table and set the document level variables.

How can i do this ?

Thanks in advance

1 Solution

Accepted Solutions
Not applicable
Author

There are a few different things you will need to do to implement this functionality. I would probably load the uid data in when all other data is loaded into the document. Then you don't have to worry about a partial reload when the macro runs.

You can set up a macro to run when the user clicks the button. In VB Script, you can use an Input Box [inputbox()] to get user input. The user input will be returned within the macro and you can use those values to populate QlikView variables. Here is a simple example:

Sub GetUserName
userNm = inputBox("Input your username")
ActiveDocument.Variables("vUserName").SetContent userNm, true
End Sub


Then, if you have your user data loaded, you probably want to select the appropriate uid based on the inputs and the data. The method you would use here would depend on how your data is set up.

View solution in original post

2 Replies
Not applicable
Author

There are a few different things you will need to do to implement this functionality. I would probably load the uid data in when all other data is loaded into the document. Then you don't have to worry about a partial reload when the macro runs.

You can set up a macro to run when the user clicks the button. In VB Script, you can use an Input Box [inputbox()] to get user input. The user input will be returned within the macro and you can use those values to populate QlikView variables. Here is a simple example:

Sub GetUserName
userNm = inputBox("Input your username")
ActiveDocument.Variables("vUserName").SetContent userNm, true
End Sub


Then, if you have your user data loaded, you probably want to select the appropriate uid based on the inputs and the data. The method you would use here would depend on how your data is set up.

Not applicable
Author

Thanks bro,

It worked for me.