11 Replies Latest reply: Jul 29, 2010 9:23 AM by Philippe Motillon RSS

    Call a macro from the load script.

      Hello,

      I am calling a macro from my load script to read a configuration file.

      It works perfectly in the Local client , using qv.exe at command line , but fails when I use the QlikviewDistribution.exe executable.

      I am using this program like that :

      "C:\Program Files\QlikView\Publisher\Distribution Service\QlikviewDistributionService.exe" -r="C:\Documents and Settings\philippe\Bureau\HUBIZ_svn\Projets\ProfitMasterCanada\QVW\Hubiz_Profitmaster.qvw" -variablename=ConfigurationFile -variablevalue="'C:\Documents and Settings\philippe\Bureau\HUBIZ_svn\Projets\ProfitMasterCanada\QVW\Hubiz-properties'"

      But it always fails with that message :

      21/05/2010 8:21:18 AM Information 05/21/10 08:21:18: 0014 Repertoire=GetE
      nv('Directory', 'C:\ProgramData\QlikTech\Documents\hubiz-properties')
      21/05/2010 8:21:18 AM Information 05/21/10 08:21:18: 0017 directory ERROR
      : Testfile, unable to create FileSystemObject

       

      Is there anything parameter to activate to make it work.

       

      I am using Version 9 SR3.

      Thanks

       

      Philippe


       

        • Call a macro from the load script.
          Rob Wunderlich

          I think you need to add the command line switch to allow system access. Do know the switch off hand, check the doc.

          -Rob

            • Re. :Re: Call a macro from the load script.

              THanks Rob,

              I went thru the entire Server Documentation and I do not see aby information on a switch that allows the System Access.

              Can you tell me where I can have a look to find that switch information ?

               

              Thanks again.

               

              Philippe

               

                • Re. :Re: Call a macro from the load script.
                  Rob Wunderlich

                  I may have steered you wrong on this one. The switch I was thinking of is for QV.exe command line.

                  Are all the directory levels in your FileSystemObject call present? Can you post the macro code?

                  -Rob

                    • Re. :Re: Call a macro from the load script.
                      Michael Solomovich

                      It's probably not directly relevant, but there is something in QVS. If I remember correctly, it is a checkbox "allow unsafe macro", or something like that.

                      • Re. :Re: Re. :Re: Call a macro from the load script.

                        Rob,

                        Here is the Macro called by the load script

                         

                        Function GetEnv(champs, ConfigurationFile)
                        '----------------------
                        'Set document variables based on the data in the configuration file
                        'File is comma-delimited ( can be something else if needed).
                        'First field on each record is variable name.
                        'Second field is variable value.
                        'First record is column labels.

                        Dim conffile, confrec, tempvar, tempvalue, recctr
                        GetEnv="GetEnv Error"
                        recctr=0
                        On error resume next
                        Set fso=CreateObject("Scripting.FileSystemObject")
                        If Err.Number <> 0 then
                        GetEnv="ERROR: Testfile, unable to create FileSystemObject"
                        Err.Clear
                        Exit Function
                        End If
                        On error goto 0

                        If not fso.FileExists(ConfigurationFile) then
                        GetEnv="ERROR: file not found : " & ConfigurationFile & "R"
                        Exit Function
                        End If

                        On error resume next
                        Set conffile=fso.OpenTextFile(ConfigurationFile,1,False,0)
                        If Err.Number <> 0 then
                        GetEnv="ERROR: unable to OpenTextFile"
                        Err.Clear
                        Exit Function
                        End If
                        On error goto 0

                        Do While not conffile.AtEndofStream 'loop through the file
                        recctr=recctr+1
                        On error resume next
                        confrec=conffile.ReadLine
                        If Err.Number <> 0 then
                        GetEnv="ERROR: unable to ReadLine"
                        Err.Clear
                        Exit Function
                        End If
                        On error goto 0

                        If left(confrec,1) <> "#" then 'ignore # record column labels
                        On error resume next
                        tempvar=Trim(Left(confrec,Instr(1,confrec,"=")-1))
                        If Err.Number <> 0 then
                        GetEnv="ERROR: unable to extract Variable"
                        Err.Clear
                        Exit Function
                        End If

                        if tempvar = champs then
                        tempvalue=Trim(Right(confrec,Len(confrec)-Instr(1,confrec,"=")))
                        If Err.Number <> 0 then
                        GetEnvErr="ERROR: unable to extract Value"
                        Err.Clear
                        Exit Function
                        End If
                        if champs = "Password" then 'Specific pattern for the password (call the decrypt function)
                        ProgramComp=Program & " " & tempvalue
                        ReturnValue=ExecuteShellProgram(ProgramComp)
                        tempvalue=ReturnValue
                        end if
                        GetEnv=tempvalue 'Assign the value found to the returned information
                        Exit Function
                        else
                        if tempvar = "Program" then
                        Program = Trim(Right(confrec,Len(confrec)-Instr(1,confrec,"=")))
                        end if
                        End If
                        End if

                        Loop 'end of loop through file

                        conffile.Close
                        'GetEnvErr=FormatNumber(recctr-1,0) + " document variables created from testfile.txt"
                        set fso=nothing
                        set conffile=nothing
                        End Function

                          • Re. :Re: Re. :Re: Call a macro from the load script.
                            Rob Wunderlich

                            Philippe,

                            I tried Michael's suggestion of setting the "Allow unsafe macros" in QVS but that doesn't seem to fix it. I tried a simple

                            Set fso=CreateObject("Scripting.FileSystemObject")

                            and that gets an Err 429 - Unable to create ActiveX Object. So it seems the problem is how to get System Access when reloading from QlikviewDistributionService.exe. I can't figure it out. Maybe time to try support if you haven't already done so. Let us know the outcome.

                            -Rob

                      • Call a macro from the load script.
                        Tom Mackay

                        Rob,

                        I think this was what you might have been thinking of, the batch switch. This is from section 24.2 of the QVS Ref Manual:

                        24.2 Reloading a file from the command line

                         

                        The following value in C:\Program Files\QlikView\Publisher\Distribution Service\QlikViewDistributionService.exe.config needs to be set to true:

                        <add key="EnableBatchMode" value="false"/>

                         

                        Tom