Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
devans_1
Creator
Creator

Writing to a text file

Does anybody know if there is a simple way of writing data to a text file ? I don't want to do anything complicated. Just input a string in an input box and then write that line of text to a .txt file. Of course, it would be better if I could write it to something a little more advanced (Excel would be good) but I am happy to start simple.

5 Replies
Not applicable

David,

There are many ways to exporting supported in qlikview but thru macros. Export charts as images, excel, into PPT, word etc. Go to you qv installation directory, QVroot\documentation\APIGuide.qvw. You can see all the possible macro based exports. eg.: ExportBitmapToFile, etc

Regards,

Kiran Rokkam.

devans_1
Creator
Creator
Author

Hi Kiran,

I took a look at this and couldn't quite find what I wanted. One of the main issues is that I want to write variables rather than fields. But you pointed me in the right direction I think. In the end I did a little macro that wrote the variables to a text file and then created a function that I can put in the script that reads them in again.

David

devans_1
Creator
Creator
Author

I am still having problems with this and any help from anyone would be gratefully appreciated.

I have done a macro to read from a text file.

It's simple and works fine when I run it online. But when I run it from the management console in background it fails. As far as I can see the error is in the

Set objFSO      = CreateObject("Scripting.FileSystemObject")

line since if I comment everything else out it still fails. I have the macro set up to allow system access and it doesn't give an error - it just fails. Does anybody have any idea what is wrong ?

function Get_Var (VariableToSet, ParamFile)
  Get_Var      = 0                ' Default value i parameter is not found.
     Set objFSO      = CreateObject("Scripting.FileSystemObject")
if objFile.size > 0 then                                             ' Check default file exists.
      Set objFile = objFSO.OpenTextFile(ParamFile, 1)
    Do While Not eof                                                   ' Read each line loop
      ParamLine = objFile.readline                                   ' Read the line
      if InStr (ParamLine, VariableToSet) > 0 then               ' Is it the default parameter required
          Get_Var = trim (mid (ParamLine, len (VariableToSet) + 2)) ' If so, strip out this name and leave the value
          exit do                                                       ' Value found so terminate
       end if
    Loop
    objFile.close                                                       ' Close the file
end if
end function



devans_1
Creator
Creator
Author

Does anybody have any ideas on this ? I am getting quite desparate and would really appreciate a more expert view on this.... !

Essentially the statement

Set objFSO      = CreateObject("Scripting.FileSystemObject")

appears to be failing when I run teh script from the management console.

Not applicable

David, the macro needs to have system access to create any object. When running through QMC its doesnt have such a permissions. I am not sure how to get this done, but you can try batch based reload with \nosecurity construct.

Kiran.