Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
anderseriksson
Partner - Specialist
Partner - Specialist

Failing ExportBitmap in Windows Task

Hi, I've got a strange problem with an automated image export.

Have a QlikView document with a number of straight tables and some different gauges.

These are to be exported into images which then can be displayed on an internal website.

I have all the tables and gauges finished as they should be and a macro for exporting them all to png-files using ExportBitmapToFile.

The png-files goes into designated folders with assigned names that the webpages can find them.

Macro works just fine when run from inside QlikView using a button as trigger, all png-files get created as expected.

Next I made a bat-file that starts QlikView with this application and setting a QlikView variable (/v switch).

In the QlikView document i Have an OnOpen trigger that calls my macro and in the
macro I'm checking if the variable is set otherwise the export is cancelled.

This also works as expected when run from the command prompt in Windows.

Finally I use this bat-file to configure a Windows Task in order to run this export on a regular basis.

Now things does not work as good any more.

I can tell that QlikView is indeed started when the Windows Task is triggered and the macro is running as expected but the images are not created!

I have other code in the same macra that creates some subfolders if they don't exists and I see this happening.

On the straight tables I tried using Export and ExportHtml instead creating text-files and webpages, then it's working.

The gauges I tried using WriteToFile instead but that was not working either.

But when using both ExportBitmapToFile and WriteToFile I do get the png-files!?!

From some further experimenting I can tell that it is the WriteToFile that is working but only if preceeded by the ExportBitmapToFile?

Commenting out ExportBitmapToFile the WriteToFile does not produce the png-file.

Unfortunately WriteToFile can't be used on a straight table as it does not exist for those only for drawn graphs and gauges.

I have ruled out license problem as QlikView is indeed running and producing things.

Also ruled out write permission problems on the folders as the Export and ExportHtml are working in those folders.

Thought it maybe might be a version problem with QlikView client thus I upgraded to a later service release and even a later version.

First I had QlikView x86 9SR2, then updated to x86 9SR7 but no change.

After that I updated to x64 10SR4 but that did not help either.

Server is a Windows 2008 64 bit server and I did verify that the bat-file was calling
the correct QlikView client by running it from the Windows command prompt.

Last thing I tried was setting it up on my local laptop as a Windows Scheduled Task and this IS working!

I do get png-files for both tables and gauges when using only the ExportBitmapToFile (no call of WriteToFile).

Conclusion, is there a macro problem when running QlikView on particular Windows servers?

Because I have this very same thing running at a different customer without these problems but I'm can't compare server versions at the moment.

Regards, Anders

1 Solution

Accepted Solutions
anderseriksson
Partner - Specialist
Partner - Specialist
Author

The problem is finally resolved.

Something obviously wrong with macro execution on that particular server.

We moved the Windows Task to a different server that had no QlikView before.

Installed QlikView and setup bat-file and Windows Task and it works!

/anders

View solution in original post

9 Replies
Miguel_Angel_Baeyens

Hi Anders,

I assume that when you test in your laptop you are creating a task within the Task Scheduler and so on, but that the copy of QlikView Desktop you are running is your own, and the Server has it's own. Make sure in the batch file keeps  QlikView open, otherwise the macro might not work as expected.

I don't know how your bat file triggered by the Windows Scheduler looks like, but this seems to work:

"C:\Program Files\QlikView10\qv.exe" /l "C:\File.qvw"

and the macro

Sub DrawChart

     Set ch = ActiveDocument.GetSheetObject("CH01")

     '' Path must be fixed

     ch.ExportBitmapToFile "C:\ChartCH01.bmp"

End Sub

Are you scheduling the qv.exe file to open instead of the batch file?

Hope that helps.

Miguel

EDIT: Using QlikView 10 SR4 build 9282

anderseriksson
Partner - Specialist
Partner - Specialist
Author

My bat-file looks like this;

"C:\Program Files\QlikView\Qv.exe" /NoSecurity /vExport=1 "C:\QlikView\Export.qvw"

Changed to the correct 'Program Files (x86)' when running x86 on Windows 64.

Bat-file is not the problem since as I said it works from the command prompt and I can tell it works also when scheduled in Windows Tasks.

The macro for exporting uses statements like this one;

    set obj = ActiveDocument.GetSheetObject("EI20")

    obj.ExportBitmapToFile filePath & "\Income20.png"

(filePath is read from a variable and is correct with a fully qualified path, no relative path)

I also have ActiveDocument.GetApplication.WaitForIdle at suitable places after making selection to let all graphs finish uppdating before attemting the export.

As I have said already the macro works when run directly inside QlikView, the bat-file works when run from a Windows command prompt and finally the Windows Scheduled Task works when configured on my laptop (yes using my own local copy of QlikView x86 10SR3). It is the Windows Scheduled Task running on the Win2008 x64 server using the servers copy of QlikView (versions x86 9SR2, x86 9SR7 and x64 10SR4) that fails producing png-files for the straight tables though it can produce png-files for gauges and it can produce text/html-files for the tables running the windows task and bat-file and macro.

The macro runs triggered by the Windows Scheduled Task, I'm way beyond simple errors like that.

Otherwise I would not get text/html-files either and neither the png-files from the gauges when using both ExportBitmapToFile and WriteToFile. I'm running test against empty folders thus not confusing older files but seeing new files actually created when running the Task.

Thanks, Anders

Miguel_Angel_Baeyens

Hi Anders,

The reason I insisted on the batch file is that ExportBitmapToFile, as far as I'm concerned, only works when the document is already opened, and that's why it runs right when QlikView is opened and you open the document from there. The "/l" parameter I used above does a reload but leaves the file open, which is not necessary but it might add some time to my example.

I'll keep testing in both my laptop with Windows 7 x64 and in a Windows 2008 Server x64 with QlikView 10 SR4 to see whether I can reproduce your issue. It might be related to drivers or .NET versions of the Server, but so far my example is working fine and creating the PNG files. I'm using a really simple file with very simple tables, and that might affect as well.

Regards.

Miguel

Not applicable

Hi Anders,

I am in the exact situation as you are in.  The windows 2008 x64 task scheduler will not export an image from QlikView.  Works when the batch file is ran by clicking on it.  I found the following work around.  If the schedule task is setup with the flag "Run only when user is logged on", it works.  For my purposes having the user always logged on is not an issue so for now it is working.

Regards,

Nay

Miguel_Angel_Baeyens

Hi Nay,


Thanks for noting that. I already have that flag because the user is always logged in (during the development). I'll try without the check to see whether it works in my environment or not.


Good one.

Miguel

anderseriksson
Partner - Specialist
Partner - Specialist
Author

Interesting with the "Run only when user is logged on" flag but that is no solution for me.

First, while testing the windows task I am logged in with the same user as the task is using thus the user was logged on but no pictures exported.

Second, this is a server where nobody is logged on normaly and certainly not this account as this is dedicated for automated tasks.

Will try to set up the task on a different server and see if that works.

/Anders

Not applicable

Hi,

When I tested this, the user was logged on and created the scheduler task with the flag run when user is logged on or not. That did not work. Next the scheduler task was changed to run only when user is logged on. That worked. The only draw back is I can't log off the user, that is just closing the mstsc window rather than log off.

This morning the exported pic arrived in my in box all automated through the task scheduler.

Another thing to note is I am using 32 bit version (I have both 32 and 64 bit version of qv.exe installed), however I don't think that makes any diff.

Regards,

Nay

anderseriksson
Partner - Specialist
Partner - Specialist
Author

The problem is finally resolved.

Something obviously wrong with macro execution on that particular server.

We moved the Windows Task to a different server that had no QlikView before.

Installed QlikView and setup bat-file and Windows Task and it works!

/anders

Not applicable

Yes U are correct.

Thank U.