1 Reply Latest reply: Nov 8, 2012 9:56 AM by Bill Britt RSS

    Can't run macro on reload

    m w

      We have a server with QV10 server and qv9 client installed.

      I have an external task (batch file) that reloads a qvw and runs the OnOpen macro in that qvw.

      The batch command is:

      "C:\Program Files (x86)\QlikView\qv.exe" /r "D:\QlikView Storage\Private Data\Source Documents\Applications\ISD\KangoGift.qvw"

       

      Now we are setting up a new server with QV10 server and QV10 client installed.

      The existing batch command fails.

      After some study on the QV10 documentation, I came up with:

      "C:\Program Files\QlikView\Distribution Service\QVDistributionService.exe" -r="E:\QlikView Storage\Private Data\Source Documents\Applications\ISD\KangoGift.qvw"

       

      This reloads the qvw without error, but the OnOpen macro does not run.

       

      Does anyone know how to run a macro on PostReload or OnOpen?

        • Re: Can't run macro on reload
          Bill Britt

          The PostReload macro will not execute when reloaded in batch or by server. The processing is done in the backend and no objects are drawn in the layout when reloading via server (which they are when reloading manually in QV developer). Because of this, macros can't access front end objects when reloaded via server. One workaround I can think of is to write a VBScript to open the QlikView document, reload, run the macro, save the document, quit QV.
          This would however require QV Standalone to be installed on the server.

           

          Steps:
          1. Create a VBScript file named something like MyVBScript.vbs with the following info:
          set Qv = CreateObject("QlikTech.QlikView")
          Set QvDoc = Qv.OpenDoc ("C:\Folder\Filename.qvw","","")
          QvDoc.Reload
          '--Add code here--

           


          '--To here--
          QvDoc.Save
          QvDoc.GetApplication.Quit

           

          ------
          You add your macro between the two comments in the code above. All commands have to be preceeded by QvDoc though as in the rest of the example above.

           

          2. Create a batch file called MyBatFile.bat and just add the path and name of the VBS file to run which was created in step 1.

           

          3. Schedule the bat file to run using QVS or Windows Scheduler.

           

          This of course has its drawbacks as you lose a lot of the task functionality in the QEMC with proper logging etc.