Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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:
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.
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
This limitation is documented in our documentation"
"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.
@Marcus_sommer Thanks for the links, which gave me some ideas.
@NadiaB Well hidden in the small print! 🙂
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:
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.