Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
- I had a qvw file with edit script.
- In front end i'll take a button in sheet. When i click this button the editscrpit code should stored in qvs file of particular folder.
I now how to generate qvs file manually.
How can i solve this problem from front end.
Hi,
For what it's worth, although I've answered in a different thread, you can use the following macro code in a button, for example
Sub SaveScript
Set docProps = ActiveDocument.GetProperties
docScript = docProps.Script
''MsgBox(docScript)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\ScriptFile.txt")
objFile.Write(docScript)
objFile.Close
End Sub
Regards.
BI Consultant
I am not able to understand your question.
If you want to save the script in a qvs or txt file, you can do it in the script editor menu File -> Export to Script File
Hope this helps.
Ya you are right...but i want to save the script in a qvs file by button click action.
Is it possible to do it.
Hi,
For what it's worth, although I've answered in a different thread, you can use the following macro code in a button, for example
Sub SaveScript
Set docProps = ActiveDocument.GetProperties
docScript = docProps.Script
''MsgBox(docScript)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\ScriptFile.txt")
objFile.Write(docScript)
objFile.Close
End Sub
Regards.
BI Consultant
Miguel,
I need some more help from you. Your code is working fine but, i'm storing the script file based on front end filteration.
Wait I'll explain you breifly in the following points:
- In sheet i had take the one list box(FieldName field) and button.
- I had created Main.qvd file with fields A,B,C,D and i loaded in the edit script like this
Main:
LOAD $(vLoadMainFields)
FROM
Main.qvd
(qvd);
- $(vLoadMainFields) this is variable i created in qvw file.
- In button i written a action for this variable like following code
variable: vLoadMainFields
value: =GetFieldSelections(FieldName,',')
- And written a macro to reload the qvw file and another macro to take back up of editscript(i.e., code given by u)
- Now i'm using the script file in another qvw file using Include statement.
- when i reload this qvw file it shows error.
B'coz this qvw file don't now the variable $(vLoadMainFields).
I'm attaching my qvw file for your reference.
How can i overcome this..
Hello,
There are several things here. Since you are reloading the document, and sicne the script excutes line by line, and since "FieldName" table has all the possible values for FieldName, you will always load all values from there.
I'd use the following expression to get the values properly formatted:
=Chr(34) & Concat(DISTINCT FieldName, chr(34) & chr(44) & chr(34)) & chr(34)
But instead of using that LOAD in your script, I'd add that in a different macro
Sub LoadOnlySelected
Set docProps = ActiveDocument.GetProperties
docScript = docProps.Script
flds = ActiveDocument.Variables("vLoadMainFields").GetContent.String
'' This is added temporarily to the actual script
docScript = docScript & "LOAD " & flds & " AUTOGENERATE 1;" '' In my example I don't have any QVDs
'MsgBox(docScript)
ActiveDocument.SetProperties docProps
ActiveDocument.Reload
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\ScriptFile.txt")
objFile.Write(docScript)
objFile.Close
Set objFSO = nothing
Set objFile = nothing
'' reset variable
ActiveDocument.Variables("vLoadMainFields").SetContent "=chr(34) & GetFieldSelections(FieldName, chr(34) & chr(44) & chr(34)) & chr(34)", true
End Sub
The result txt file will store the actual script plus the "LOAD A, B, C AUTOGENERATE 1;" line which should work.
Hope that helps
BI Consultant
Miguel,
Is it possible to transfer a variable from one qlikview file to another qlikview file with content of that variable.
Meanwhile i'll check your code..
Thanks a lot.
Hello,
It's not possible, the same that when you copy an object (with dimensions and expressions) and if those fields don't exist in the destination document, the chart will render null or nothing or show some error.
Anyway, you can try to load those variables in a table and export or store this table into a text file, so you can use it later in an $(include=) in you script.
Hope that helps.
BI Consultant
Miguel,
Yes your are right when we copy object without fields load in another qvw file, the chart shows null. Actually in previous posts i explained you that what ever i select in the listbox i'm storing in one global variable. When i click the button i should transfer to another qvw file along with this global variable.
Now the think is i want to use this global variable in another qvw file to load qvd file.
Miguel,
I had seen the code in following link..
http://qlikcommunity.org/forums/t/36985.aspx
You see once and get back to me b'coz for me it is not working.