Discussion Board for collaboration on QlikView Scripting.
I have to run a Command Line to remove some variables (strings) from an external text file.
I just need to know if it is possible and how to write a Command Line into the Macro.
Thanks in advance
Hi Mirco,check this doc: Useful Qlikview Macros
I think you are searching for the first example.
Thanks for your quick answer,
I wasn't exactly looking for that, because I have many string variables, then I would like to WRITE the command line directly into the Macro in order to set my Variable.
I was also thinking to set some parameters, but I have no idea how to do it.
Ok, I thought you wanted to execute some bat that does the job.
I didn't done something like this (removing strings from external file) but but still I think it's possible, you can start with:
Set objFS = CreateObject("Scripting.FileSystemObject")strFile = "Path\File.Extension"Set objFile = objFS.OpenTextFile(strFile)
From there you'll need to find the vbscript code to do the work you wanted.
If you want a function to assign values you can use:
Function SetVariable(variable, value)
Set v = ActiveDocument.Variables(variable)
v.SetContent value, true
Hope this helps
I'll try to make it easier for you, there should be some misunderstanding, follow the command line I have to execute:
Path\sbs.exe -c --remove Path\FileName.txt StringToRemove
StringToRemove is the string variable that i need to remove.
Is there a way to write it into my Macro?
Or is there a way to run a batch file with StringToRemove as a parameter?
Sorry Mirco, probably I still don't understand the question, I'll make a simple 'show value' example hoping will help you to find the solution...
If you have a batch.bat file than contents:
and you create this macro:
Executing CallExample macro from a button in Qv will show 'MyMessage' in cmd windows.
If you need to make the parameter more dynamic you can use a function like:
GetVariable = v.GetContent.String
Then you can create the macro:
CreateObject("WScript.Shell").Run("c:\Test\batch.bat " & GetVariable("MyStringVar"))