Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
spandita
Partner - Contributor
Partner - Contributor

Macro to generate xlsx works fine manually but not from the batch through QlikviewManagement Console

Hi,

I am trying to export few charts to Excel (.Xlsx format) through Qlikview Macro and to save it on postrelaod at a particular location. The file works perfectly fine when it is run manually or from the batch (.bat) on double click. But when scheduled to run from the Qlikview Management Console through the external File(.bat file)its generating the Excel Extract but the file is blank. The error is: 'Error: Paste method of Worksheet class failed'. I have checked the permission/location of the file and its not an issue. Please help, its really urgent.

 

Thanks,

Spandita

6 Replies
dplr-rn
Partner - Master III
Partner - Master III

Does the server have office installed locally?
i think it may need it if you are using worksheet object
spandita
Partner - Contributor
Partner - Contributor
Author

Yes, Office is installed. Other qvw files works fine from the server and generate excel extract
Brett_Bleess
Former Employee
Former Employee

Had to find an article to be sure, but I did find one, I just had to update things as the version info was not updated, but this is working as expected given macros will not run via Publisher/Reload Engine when using OnPostReload or OnPostReduceData trigger, those are ignored in this case.  This is mainly due to conflict between the 'task' trying to shut things down post reload, and the trigger trying to run things for a little further explanation.

Here is the article link:  Article

Regards,
Brett

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.
jerrysvensson
Partner - Specialist II
Partner - Specialist II

I guess you are using the same macro code in this app as the ones that is working.

The sheet where the exported diagram reside has to be active. You can do this on the macro.
ActivateSheet()
Add a pause to wait for refresh of diagram. Look in API, it is sleep or wait.
spandita
Partner - Contributor
Partner - Contributor
Author

We have tried both options. The document got stuck and did not run at all after the pause.

 

We also tried adding  ActivateSheet() as a post reload trigger before running the post reload macro..Manual refresh is working fine as well as from windows batch file.But not running when the batch file is triggered from qmc.

I am using following script in batch( .bat) file

"C:\Program Files\QlikView\Qv.exe" /l "\\Filepath\filename.qvw"

Exit

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Hi

You can't use a trigger to Activesheet. It has to be in the macro. All triggers runs in its own scope.

Running it from QMC requires a license for the qlikview publisher service account also. 

Put this in your macro sub:

ActiveDocument.ActivateSheet you need to add which sheet to activate. Look in the API 
ActiveDocument.GetApplication.Sleep 1000  One second sleep


Then run your excel export code