Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
NikVladi
Contributor II
Contributor II

Is it possible to create a document variable using vbs?

If yes, then how? Need something like this:

ActiveDocument.Variables.Create("myNewVariable")

Labels (3)
2 Replies
NikVladi
Contributor II
Contributor II
Author

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

For what it's worth, here's the standard bit of code I use in my QV Modules for setting, getting and creating Variables.

Rem *** Returns a Variables content as String
Function GetVariableString(varname)
GetVariableString = GetVariable(varname).GetContent.String
End Function

Rem ** Gets a variable and creates it if it doesn't exist
Function GetVariable(varname)
If typename(ActiveDocument.GetVariable(varname)) <> "Variable" Then
ActiveDocument.CreateVariable(varname)
ActiveDocument.GetVariable(varname).SetContent "", True
End If
Set GetVariable = ActiveDocument.GetVariable(varname)
End Function ' GetVariable

Rem ** Sets a Variable's value
Sub SetVariable(varname, value)
GetVariable(varname).SetContent value, False
End Sub

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com