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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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")

2 Replies
NikVladi
Contributor II
Contributor II
Author

rwunderlich
MVP
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