Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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
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
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.
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
Many Thanks FlipSide exactly what I was looking for.
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
Really perfect many thanks another time
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)
The APIGuide.qvw is what you need. There's no intellisense for the module unfortunately.
Many thanks Flipside