Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Unable to set the variable name

<body><p>Hi All,</p> <p>I am trying to set a variable with the sheet name and want to use that variable value in edit script to filter data set further. </p> <p>I doing this in the following steps:</p> <p>Step 1&gt; Setting the variable name with the sheetname sub SheetSelection set vSheetName = ActiveDocument.ActiveSheet.GetProperties.Name end sub </p> <p>Step 2&gt; Calling this macro at OnActivateSheet event. </p> <p>Step 3&gt; On the basis of variable vSheetName, loading the following fields in the edit script  and getting Error message at the time of loading data : &lt;Field not found - vSheetName&gt;</p> <p>Load <br />     &lt;Field1&gt;,<br />     &lt;Field2&gt;,<br />     &lt;Field3&gt;<br />      resident Directory<br />      where &lt;Field4&gt; = vSheetName;</p> <p>Please have a look and let me know where i am going wrong. </p> <p>Thanks in advance<vsheetname></vsheetname></p></body>

4 Replies
SunilChauhan
Champion II
Champion II

i thing variable will be access using

set v = ActiveDocument.Variables("vControl")

Sunil Chauhan
Not applicable
Author

Try Using

V = Activeocument.ActiveSheet.Variables('Variablename")

Strongs,

Not applicable
Author

Thanks for the reply. I used following expression

Load
<Field1>,
<Field2>,
<Field3>
resident Directory
where <Field4> = = ActiveDocument.Variables("vSheetName");
but it is giving following error,

ACTIVEDOCUMENT.VARIABLES is not a valid function.

Any other way?

Not applicable
Author

Hi mansi

A macro variable is not seen by QV load script.

Make sure your variable exists or create it first (Settings/Variable Overview)

In your macro use

set v = ActiveDocument.GetVariable("vSheetName")
v.SetContent "<sheetname>",true

check with Settings/Variable that you have the correct content in the variable.

In the load refer to the variable with $(vSheetName)

Good luck

Juerg