Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to list all the variables in a table box

Hi All,

Most of the time when I'm develooping an app, I'm building some textboxes to let me know some variables values.

I'm wondering if it's possible to create a macro for exemple that will populate a tablebox with:

VarName | Value

Var1 | Value1

Var2 | Value2

...

I started to write something like:

Sub ExtractVars

          Set VariableCollection = ActiveDocument.GetVariableDescriptions

  For i = 0 to VariableCollection.Count - 1

            Set tempVar = VariableCollection.Item(i)

    tempVarName = tempVar.Name

    tempVarValue = tempVar.Value '(not running)

  Next

End Sub

But how first to get the variable value and then to store it, if feasible in a table?

1 Solution

Accepted Solutions
flipside
Partner - Specialist II
Partner - Specialist II

Create an empty Inputbox object and note the object reference.

Create this macro subroutine ...

sub ShowVars

    rem ** Show name of all variables in document **

    set vars = ActiveDocument.GetVariableDescriptions

    set IB = ActiveDocument.GetSheetObject("IB01")

    for i = 0 to vars.Count - 1

        set v = vars.Item(i)

        'msgbox(v.Name & "=" & v.RawValue)

       

        'Add to InputBox object (IB01)

        IB.AddVariable v.Name

    next

end sub

Add a button to call this code. Voila!

flipside

View solution in original post

9 Replies
hic
Former Employee
Former Employee

You could probably do it by saving into a file and then running the script. But I wouldn't use VB at all for this. I would instead define it in the load script, e.g. through

For each vVariable in 'vVar1', 'vVar2', 'vVar3'

          Load

                    RowNo() as RecNo,

                    '$(vVariable)' as VariableName,

                    '$($(vVariable))' as VariableValue

                    Autogenerate 1;

Next vVariable

HIC

Not applicable
Author

Thanks Henric,

But with that solution it means that I'll have to write the complete list of the used variables. The Idea I've is also to get the complete list of vars.

flipside
Partner - Specialist II
Partner - Specialist II

Create an empty Inputbox object and note the object reference.

Create this macro subroutine ...

sub ShowVars

    rem ** Show name of all variables in document **

    set vars = ActiveDocument.GetVariableDescriptions

    set IB = ActiveDocument.GetSheetObject("IB01")

    for i = 0 to vars.Count - 1

        set v = vars.Item(i)

        'msgbox(v.Name & "=" & v.RawValue)

       

        'Add to InputBox object (IB01)

        IB.AddVariable v.Name

    next

end sub

Add a button to call this code. Voila!

flipside

Not applicable
Author

Many Thanks FlipSide exactly what I was looking for.

flipside
Partner - Specialist II
Partner - Specialist II

Quite useful for me this, too.  If you want to ignore system variables, wrap this code around the AddVariable command ...

If Not(v.IsReserved) and Not(v.IsConfig) then

     IB.AddVariable v.Name

End if

flipside

Not applicable
Author

Really perfect many thanks another time

Not applicable
Author

Do you know where can be find the different properties of vb object that are availble in qlikview (or a way to get a kind of automatic completion in edit module)

flipside
Partner - Specialist II
Partner - Specialist II

The APIGuide.qvw is what you need. There's no intellisense for the module unfortunately.

http://community.qlik.com/message/324039#324039

Not applicable
Author

Many thanks Flipside