Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
sergio
Contributor III
Contributor III

Macro from batch to export jpg and excel problem

Hi to all, i have a little problem with this theme.

I have a macro after reload the application to do an automatic mail delivery of the data. The mail has two excel files attached and an image of a screenshot from the first tab of the qv application in their body.

The version of QV is 9.0 SR4 64bit. When i open the application and run the reload the process, the mail is delivered perfectly, but the problem is that i need to run the reload from a .bat file.

So, i've created a .bat with the following command line:

"c:\Program Files\QlikView\QV.exe" /l /vLanzar=1 /NoSecurity "E:\ProyectosQlikView\_Ventas\Datamart_Ventas\Publicacion\Pub_DatamartVentas.qvw"

it runs ok, do the reload and the mail (the excels are perfect too), but the image of the screenshot from the application is not completed, here is it:

error loading image

The code to extract the image is this:



ActiveDocument.ActivateSheet(

"Resumen")

ActiveDocument.ActiveSheet.ExportBitmapToFile(

"E:\Interfaz\Output\Llamadas_pymes.jpg")





I thought that it was for the time of QV, that it was too fast from changin to the tab with activatesheet, so i used the function waitforidle between the activatesheet and the export; again it works perfect if i run it manually, but the batch process halt in the waitforidle and never continues...

I need to do this way or with the publisher, but i know that the publisher doesn't runs macros, indeed i tested it and doesn't work really, the publisher never runs the macro.

How can i do this?? Any help will be very grateful

Greetings!

1 Solution

Accepted Solutions
sergio
Contributor III
Contributor III
Author

After a complete day trying to solve this problem, i found a possible solution. I have used the concept of a make.

Back, i needed to do an automatic reload that runs a macro after reload to send a few mails with several excels and in the body of the mails paste an image of the dashboar of the qv aplication.

In the place i work, the automatic reload can be started only by two forms: 1) QV Publisher (Impossible because it doesn't run macros)

2) A batch file (.bat) that has the rutine to launch the program with reload.

So, option 2 was the only one for me, but the macro works very different if they are started from a command line (the waitforidle doesn´t work very well, and the qv.exe opens always minimized, so the image isn't complete), and i had several problems to export the image to the body of the mail.

The solution for me: create a new qv application that his only job was to reload himself and the others, like a make file to compile, but the reloads of the others are started from the macro of this new qv app. So i can launch the reload with all the parameters of the run method, and i can use the waitforidle without surprises, maximize the application and export the image to the mail perfectly.

The line was, in the new qv script:

Qvshell = CreateObject("wscript.shell")

Qvshell.run """C:\Program Files\QlikView\Qv.exe"" /l /vLaunch=1 /NoSecurity"&vAppWithInfo,3,false

where vAppWithInfo is the qvw that runs a script to send the emails. I loaded it in a Load Inline sequence with others qvw. And this new applicatios is started from a .bat, but works fine because it doesn't have a waitforidle or some export to img.

Regards!

View solution in original post

2 Replies
sergio
Contributor III
Contributor III
Author

After a complete day trying to solve this problem, i found a possible solution. I have used the concept of a make.

Back, i needed to do an automatic reload that runs a macro after reload to send a few mails with several excels and in the body of the mails paste an image of the dashboar of the qv aplication.

In the place i work, the automatic reload can be started only by two forms: 1) QV Publisher (Impossible because it doesn't run macros)

2) A batch file (.bat) that has the rutine to launch the program with reload.

So, option 2 was the only one for me, but the macro works very different if they are started from a command line (the waitforidle doesn´t work very well, and the qv.exe opens always minimized, so the image isn't complete), and i had several problems to export the image to the body of the mail.

The solution for me: create a new qv application that his only job was to reload himself and the others, like a make file to compile, but the reloads of the others are started from the macro of this new qv app. So i can launch the reload with all the parameters of the run method, and i can use the waitforidle without surprises, maximize the application and export the image to the mail perfectly.

The line was, in the new qv script:

Qvshell = CreateObject("wscript.shell")

Qvshell.run """C:\Program Files\QlikView\Qv.exe"" /l /vLaunch=1 /NoSecurity"&vAppWithInfo,3,false

where vAppWithInfo is the qvw that runs a script to send the emails. I loaded it in a Load Inline sequence with others qvw. And this new applicatios is started from a .bat, but works fine because it doesn't have a waitforidle or some export to img.

Regards!

spandita
Partner - Contributor
Partner - Contributor

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