Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikconsultant
Creator III
Creator III

Macro is not triggered on server reload?

I created the following VB macro:

 

 

SUB ExportTest

if(Weekday(date)) = "6" Then
SET ExportTable = ActiveDocument.GetSheetObject("CH243")
ExportTable.Export "D:\Data\Test\Test2\Test_"&date&".csv", ";" 

End If

END SUB

 

 

and created a document trigger "OnPostReload" to start the macro.

If I do a reload the app in the local client it runs fine, on the server nothing happens. 

What do  I miss?

Labels (2)
1 Solution

Accepted Solutions
qlikconsultant
Creator III
Creator III
Author

For all those who have the problem, here is my workaround:

1) In QlikView go to Tools => Edit Module

Insert you export script here an example:

SUB ExporttoCsv
SET ExportTable = ActiveDocument.GetSheetObject("Objectcode like CH04")
ExportTable.Export "Path&Filename.csv", ";" 
END SUB

In Edit Module:

  • Set Scripting Engine to “VBSCript”.
  • Set Requested Module Security “System Access”
  • Set Current Local Security to “Allow System Access”

Run the test and be sure that is correct saved.

2) Create a trigger in “OnPostReload”. The Trigger is “Run Macro” and you use the macro name, in this example ”ExporttoCsv”.

If you reload the file now it should work but not on the server.

3) For automated reload create a cmd file with the following code:

"C:\Program Files\QlikView\Qv.exe" /r c:\yourpath\your file.qvw

Then create a job in the windows “Task Scheduler” to run the reload on a schedule.

View solution in original post

4 Replies
marcus_sommer

It's not possible - at least not directly. You will always need to execute it with the desktop client but such tasks might be triggered from the qmc. To implement such things isn't trivial and depending on your environment and the targets it could be quite difficult.

There exists already a lot of postings to the topic which you could find within the community (looking there directly or per google). Here some links as starting point for further investigations:

How to Run macros in QMC - Qlik Community - 985383

Solved: Macro not running in task - Qlik Community - 751

Run Excel macro via QMC - Qlik Community - 1133941

- Marcus

NadiaB
Support
Support

Hi @qlikconsultant 

This limitation is documented in our documentation"

https://help.qlik.com/en-US/qlikview/May2022/Subsystems/Client/Content/QV_QlikView/UsingMacrosonQVS....

"The following triggers are not to be used in the QlikView Server environment, since they lack meaning or may cause unexpected results:

OnPostReduceData

OnPostReload"

We recommend to verify limitations for macros running on Server prior developing a solution to make sure that the functionality is supported. 

Don't forget to mark as "Solution Accepted" the comment that resolves the question/issue. #ngm
qlikconsultant
Creator III
Creator III
Author

@Marcus_sommer Thanks for the links, which gave me some ideas.

@NadiaB Well hidden in the small print! 🙂

qlikconsultant
Creator III
Creator III
Author

For all those who have the problem, here is my workaround:

1) In QlikView go to Tools => Edit Module

Insert you export script here an example:

SUB ExporttoCsv
SET ExportTable = ActiveDocument.GetSheetObject("Objectcode like CH04")
ExportTable.Export "Path&Filename.csv", ";" 
END SUB

In Edit Module:

  • Set Scripting Engine to “VBSCript”.
  • Set Requested Module Security “System Access”
  • Set Current Local Security to “Allow System Access”

Run the test and be sure that is correct saved.

2) Create a trigger in “OnPostReload”. The Trigger is “Run Macro” and you use the macro name, in this example ”ExporttoCsv”.

If you reload the file now it should work but not on the server.

3) For automated reload create a cmd file with the following code:

"C:\Program Files\QlikView\Qv.exe" /r c:\yourpath\your file.qvw

Then create a job in the windows “Task Scheduler” to run the reload on a schedule.