Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everybody,
In one of our apps, we have a macro in edit module as follows:
sub ExportRowCount2
set chart = ActiveDocument.GetSheetObject("CH113")
ActiveDocument.Variables("vNumRows2").SetContent chart.GetNoOfRows, true
end sub
And, defined vNumRows2= $(vNumRows2) in the qvs file where we define all variables.
I am calling this qvs file into the qvw. But when I am reloading the app, I am not able to see this variable in the variable overview.
Please advise on this.
Thanks!
Vindhya,
The "vNumRows=$(vNumRows)" code defines a vNumRows as a "reference" to existing definition of the vNumRows variable.
It seems like strange approach, but it allows to keep the defined variable after reload.
Using "let vNumRows=1", for example, will reset this variable to 1 every time the app is reloaded.
Using the code above will allow you to keep the last definition of the variable in the file after the reload.
But this approach does not work until you define this variable the first time (otherwise it's reference to null: "vNumRows=NULL").
So, you have to create the new variable (vNumRows2) in the app's Variables Definition dialog first and than use the code like "let vNumRows2=$(vNumRows2)" in the script.
Hope it helps.
Vlad
Hi,
can you provide a snapshot of code in which we can see the assignment?
In qvs you might to assign the value in this way:
SET vNumRows2= $(vNumRows2);
S.
Hi Simone, Here are the screenshots. I have tried SET also but still I am not getting the variable in the app.
Script in edit module:
qvs file:
Thanks!!
A variable that is null at the end of the script will not get "promoted" to the variable overview. It will get dropped at script end.
So if the variable doesn't currently exist, you can't create it by referring to itself.
LET vNumRows = $(vNumRows)
So you will need to set it to something at least once. Perhaps set it conditionally.
LET vNumRows = if(len('$(vNumRows)')>0, $(vNumRows), 0)
-Rob
Hi Rob,
In my case, the first vNumRows is visible in the variable overview and the vNumRows2 is not.
Please advise
Thanks!
Re-Read my post and substitute vNumRows2 for vNumRows. I only used vNumRows as the example, I believe it's the same problem,
-Rob
Hi Rob,
My concern is that when one of the variables is working, why not the other one? both of them are defined in the same way. Please refer to my screenshots in previous post. Also, there is another application with similar code in edit module and the similar variables in the qvs file. That application is working fine.
I am trying to figure out if I am missing any step. Can you suggest of any step that you think I am missing according to my screenshots?
Also, I tried to use the example which you suggested in your post, it is giving the following error when reloaded:
Please advise
Thanks!
Add some quotes to avoid the syntax error when the variable is null.
LET vNumRows = if(len('$(vNumRows)')>0, '$(vNumRows)', 0)
I can't tell you why one of your variables is working and the other doesn't. I can tell you that a variable that is empty in the script does not get promoted to the UI. And a variable that doesn't exist in the UI can't be set by
ActiveDocument.Variables("vNumRows2").SetContent
If you want to "fix" it, why not just define the variables once in the variable overview. Or just hard cod the variables in the script like:
SET vNumRows=1;
-Rob
Vindhya,
The "vNumRows=$(vNumRows)" code defines a vNumRows as a "reference" to existing definition of the vNumRows variable.
It seems like strange approach, but it allows to keep the defined variable after reload.
Using "let vNumRows=1", for example, will reset this variable to 1 every time the app is reloaded.
Using the code above will allow you to keep the last definition of the variable in the file after the reload.
But this approach does not work until you define this variable the first time (otherwise it's reference to null: "vNumRows=NULL").
So, you have to create the new variable (vNumRows2) in the app's Variables Definition dialog first and than use the code like "let vNumRows2=$(vNumRows2)" in the script.
Hope it helps.
Vlad
Thanks Vlad.