2 Replies Latest reply: Sep 7, 2016 12:52 PM by Ben O'Hara RSS

    Writing to a text file from publisher

    Ben O'Hara

      Hi,

      I have a QVW who's sole job is to download data and put it into a QVD, however it's not a straight forward as that!

      The data comes from a website on our network, but it requires logging into with a username and password, then saves the results as a CSV file.

      I'm using the VBScript module to do the logging in and downloads, which puts the CSV data into a variable. The problem I'm having is writing that to a file, so I can then import it into the QVD.

       

      I tried adding it into a temp table and storing it, but as it's properly formed CSV, with quotes, comment lines and everything, the outputted file has everything double quoted with extra quotes at the beginning and end. I tried adding no quotes to the format-spec, but that's for load only apparently.

       

      My next attempt is to write another VBScript macro that takes the variable and writes it to a file using FileSystemObject.

       

      Function WriteFileText(sFilePath, sText)

      dim r on error Resume next

            with CreateObject("Scripting.FileSystemObject")

      if err<>0 then r="Error Creating Object:" & err.description

           if err=0 then

              with .CreateTextFile(sFilePath, True)

              if err<>0 then r= "Error Creating File:" & err.description

              if err=0 then

                .Write sText

                if err<>0 then WriteFileText="Error writing text:" & err.description

                .Close

             end if

              end with

              end if

          end with WriteFileText= r

      End Function

      This works perfectly when run from the QlikView application and I'm very happy with it, but I want this to be a scheduled task, run by the  publisher, but the script fails at the CreateObject line with the message

      ActiveX component can't create object

      I'm developing as the same user as the Publisher service is running on, so far as I can tell all the macro settings are on allow system access, but I can't see where to set this for the publisher.

      Any suggestions?