Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
chrisg
Partner - Creator III
Partner - Creator III

Print a list of variables?

How is it possible to print a list of all my variables?

thx

Chris

Do or Do Not. There is no try!
1 Solution

Accepted Solutions
chrisg
Partner - Creator III
Partner - Creator III
Author

Here we go:

http://qlikviewmaven.blogspot.com/2008/11/listing-all-variables-and-contents.html

a very smart Marco for EXECL

Sub List_QV_Variables()
'This Excel macro will ask you to select a QlikView Report File and
'then it will put the variable names and contents into your current worksheet
'--Tim Benoit, Nov 2008
Dim oQV, oRpt, oVars, oTempVar, oThisVar, qv_fn

'Get the QlikView report pathname
qv_fn = Application.GetOpenFilename("QlikView Report File (.),*.*", , "Select a QlikView .qvw Report File", False)
If qv_fn = 0 Then
Exit Sub
End If

'Write out some heading text
ActiveSheet.Cells(1, 1).Formula = "QlikView Variables List"
ActiveSheet.Cells(2, 1).Formula = "Report pathname:"
ActiveSheet.Cells(2, 2).Formula = qv_fn
ActiveSheet.Cells(3, 1).Formula = "Variable Name"
ActiveSheet.Cells(3, 2).Formula = "Variable Content"

'Open the QlikView report file
Set oQV = CreateObject("QlikTech.QlikView")
Set oRpt = oQV.OpenDoc(qv_fn)
Set oVars = oRpt.GetVariableDescriptions
'Loop through the variables
For i = 0 To oVars.Count - 1
Set oTempVar = oVars.Item(i)
varname = Trim(oTempVar.Name)
Set oThisVar = oRpt.Variables(varname)
varcontent = oThisVar.GetRawContent
'Write data into worksheet cells
ActiveSheet.Cells(i + 4, 1).NumberFormat = "@"
ActiveSheet.Cells(i + 4, 1).Formula = varname
ActiveSheet.Cells(i + 4, 2).NumberFormat = "@"
ActiveSheet.Cells(i + 4, 2).Formula = varcontent
Next

'Close QlikView
oRpt.CloseDoc
oQV.Quit
End Sub

Do or Do Not. There is no try!

View solution in original post

2 Replies
chrisg
Partner - Creator III
Partner - Creator III
Author

Here we go:

http://qlikviewmaven.blogspot.com/2008/11/listing-all-variables-and-contents.html

a very smart Marco for EXECL

Sub List_QV_Variables()
'This Excel macro will ask you to select a QlikView Report File and
'then it will put the variable names and contents into your current worksheet
'--Tim Benoit, Nov 2008
Dim oQV, oRpt, oVars, oTempVar, oThisVar, qv_fn

'Get the QlikView report pathname
qv_fn = Application.GetOpenFilename("QlikView Report File (.),*.*", , "Select a QlikView .qvw Report File", False)
If qv_fn = 0 Then
Exit Sub
End If

'Write out some heading text
ActiveSheet.Cells(1, 1).Formula = "QlikView Variables List"
ActiveSheet.Cells(2, 1).Formula = "Report pathname:"
ActiveSheet.Cells(2, 2).Formula = qv_fn
ActiveSheet.Cells(3, 1).Formula = "Variable Name"
ActiveSheet.Cells(3, 2).Formula = "Variable Content"

'Open the QlikView report file
Set oQV = CreateObject("QlikTech.QlikView")
Set oRpt = oQV.OpenDoc(qv_fn)
Set oVars = oRpt.GetVariableDescriptions
'Loop through the variables
For i = 0 To oVars.Count - 1
Set oTempVar = oVars.Item(i)
varname = Trim(oTempVar.Name)
Set oThisVar = oRpt.Variables(varname)
varcontent = oThisVar.GetRawContent
'Write data into worksheet cells
ActiveSheet.Cells(i + 4, 1).NumberFormat = "@"
ActiveSheet.Cells(i + 4, 1).Formula = varname
ActiveSheet.Cells(i + 4, 2).NumberFormat = "@"
ActiveSheet.Cells(i + 4, 2).Formula = varcontent
Next

'Close QlikView
oRpt.CloseDoc
oQV.Quit
End Sub

Do or Do Not. There is no try!
bullish35
Creator II
Creator II

Thank you for posting this!