Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
david_ze
Partner - Contributor III
Partner - Contributor III

Run a macro on post reload

Hi All, I'll appreciate your help on a problem I have.

I'm loading data from QVD files and I'd like to send some views via email.
I've wrote macro to send those views (it works fine), and set a triger to run the macro on post reload.
I'm loading the data by using a batch file, the batch works ok...data is reloaded buy some how the macro in not excuted on post reload.
Any idea what could be th problem ?


Thanks,
David

9 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

To my knowledge, you cannot run macros in Server OnPostReload.

-Rob

http://robwunderlich.com

Not applicable

problem : can't set macro to allow system access from RELOAD (option /r not work)

Ref : http://community.qlik.com/message/18973

Ref : http://community.qlik.com/message/21833

Ref :       http://community.qlik.com/message/165717

1.Create Batch file  ==> "C:\Program Files\QlikView\qv.exe" /l "path_to_document"

2.Create Task Scheduler to RUN Batch file (1)

3.QVW Document ==> Document properties > OnPostReload ==> Add RUN MACRO

4.add  (end of script)

       ActiveDocument.Save

   Application.Quit

don't forget

1. User Preference >Security > select "Module..." and "File.."

2. Document Properties > Security > Macro Override Security

Brett_Bleess
Former Employee
Former Employee

If you are using the /r parameter in your batch file, you have a conflict, and OnPostReload is likely not going to work, as /r is set to do the reload, save the document and quit, but you are attempting to put an OnPostReload trigger in as well, so you have a conflict between the /r functionality and the OnPostReload trigger.  You will have to design another means of trigging things to avoid the conflict.

One other thing to consider is if you can create the views you mention in QlikView Reports, and you have the Publisher PDF Generator feature in your Publisher license, you can email PDF versions of the Reports to users using Publisher to handle everything.

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
wcushy
Contributor
Contributor

Hi

Not sure if you have this answered yet, i have the same process and it works ok for me. the first questions that should be asked is what version of Qlikview are you running and can you give an example of the macro you have created.

Also how are you running the batch file, are you using windows task scheduler or some other third party software. I use visual cron and have to force the batch file to run in the forground for it to work correctly as the batch process does not work properly when run in the background.

Not applicable

Hi Rob,

I have a simillar issue where I previously run post reload tasks that exported Excel files from object tables without any issues during the night when no-one was in.  I have since moved the task to QV 11 server and suddenly the object cannot be created.  Yet I do have the macro setting the same in the module.

Is this some functionality lost with 11 or am I missing something undemental here?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Peter,

Are you running a macro in OnPostReload?

Does your server have the setting "Allow unsafe macro execution on server" set on?

-Rob

Not applicable

Hi Rob,

Will batch file works in QV server to export tables to excel, post reload? Otherwise, what could be the solution if we want to export table to spreadsheets post reload, after migrating to QV server?

buzzario
Contributor II
Contributor II

Dear Ongart,

I also have a macro that creates an excelfile and sends it out by mail postreload and it works fine. I use it to check if all fields are filled in correctly in an important database which can block invoicing if not filled in correctly. But most of the time this report is empty. I would like to include a line in the macro, or even in the Qlik script some sort of IF(REP1=Empty, don't run macro, run macro).

I've tried adding 'if filesize < 10kb then quit application' but that just gave an error in the script, although I've looked up syntax online.

Now somebody told me it is possible to add the IF in the Qlik-script itself, but I don't seem to find the right scripting for this anywhere. Can you help me one way or the other? Final mission is that the report isn't sent by mail (or that macro doesn't run) if it's empty.

tglanz
Contributor II
Contributor II

This was exactly what I was looking for.

It worked on first trial.

I export via a macro a XML table and a .qvd and close after reload.

just perfect.

Thank You!

Thomas Glanz