Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
salezian
Creator
Creator

Macros on server

Hi Everyone

I'm trying to reload using scheduler QlikView document containing two macros. Macros are used to count files in folder and delete files. Here is example of macro's code:

public function DeleteFile(filePath)

   Set objFSO = CreateObject("Scripting.FileSystemObject")

   Dim retVal 'as Boolean

   If objFSO.FileExists(filePath) Then

      Call objFSO.DeleteFile(filePath)

      retVal = true

   Else

Set objFSO = nothing

      retVal = false

   End If

   DeleteFile = retVal

end function

Locally those macros work fine. But when document is refreshed by scheduler I got general error as a result.

Is there any workaround to launch document on server ?

Regards.

M

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The CreateObject("Scripting.FileSystemObject") call requires your module to have System Access. To get System Access from the command line, you have to add the switch /NoSecurity.

QV.exe /r /NoSecurity path_to_qv_file


-Rob

http://masterssummit.com

http://robwunderlich.com



View solution in original post

13 Replies
vikasmahajan

In scheduler macros never work , you need to run through batch file.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
salezian
Creator
Creator
Author

Thanks for answer. Should I schedule file using system scheduler ?

jerrysvensson
Partner - Specialist II
Partner - Specialist II

If possible use an External program task.

Everything in one place and you can use depency also.

salezian
Creator
Creator
Author

Unfortunately still doesn't work. Reload is starting but macro doesn't work. It returns null.

Below is macro's code:

public function countFiles(directoryPath)


     Dim noOfFiles,objFSO,objFolder

     Set objFSO = CreateObject("Scripting.FileSystemObject")

     Set objFolder=objFSO.GetFolder(directoryPath)

     noOfFiles=0

     for each file in objFolder.files

          if LCase(objFSO.GetExtensionName(file)="xls") then

               noOfFiles=noOfFiles+1

          end if

     next

     countFiles=noOfFiles

end function

Would be grateful for any help.

jerrysvensson
Partner - Specialist II
Partner - Specialist II

What is your inparams?

C:\<dir> or for instance z:\<dir> ?

When you run it in Publisher, it will run in service account that may not have the same drive mapping as your user.

salezian
Creator
Creator
Author

I run  it using bat file (QV.exe /r path_to_qv_file)

In script I set folder name. Example below:

vFlatFilesPath='C:\ProgramData\QlikTech\Documents\Tesco\Data\FlatFiles'

Let vNoOfFiles=countFiles('$(vFlatFilesPath)');

Regards.

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Ok

Does your service account have a license?

What does the logfile say?

salezian
Creator
Creator
Author

Yes it has.

As I said I try to run it using batch file. Log says that variable vNoOfFiles is null (but when run locally it works fine).

Bill_Britt
Former Employee
Former Employee

Hi,

Can you explain what you mean by "but when run locally it works fine". I would think this would have to be ran on the machine that you are wanting the work done on.

Bill

Bill - Principal Technical Support Engineer at Qlik
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.