Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ob
Partner - Contributor II
Partner - Contributor II

Export from document to several jpg files

I have a document with a macro at the OnPostReload. In this macro I want to export several images with different selections. The macro looks like this:



sub exportGraphToDisc
GraphPath = "c:\ba"

ActiveDocument.Fields("MAINLOCATION").Select "Ula"
ActiveDocument.Fields("LOCATIONCODE").Select "ULA"
ActiveDocument.Sheets("Main").ExportBitmapToFile GraphPath & "a1.jpg"

ActiveDocument.Fields("MAINLOCATION").Select "Valhall"
ActiveDocument.Fields("LOCATIONCODE").Select "VAL"
ActiveDocument.Sheets("Main").ExportBitmapToFile GraphPath & "a2.jpg"
end sub

What happens is that when the macro is finished, the document show correct on the scrren, but both images are identical and shows the values as they were before the macro was started. It looks like the export is executed correct, but that the Select statements are running after the macro has been closed. Does somebody know if it is possible to force the execution of the ExportBitmapToFile inside the macro or are there any other solution?

Thanks



1 Solution

Accepted Solutions
johnw
Champion III
Champion III

It's possible that the chart hasn't finished responding to your selections by the time you export. To force it to wait for the changes to complete, use ActiveDocument.GetApplication.WaitForIdle between setting the fields and exporting the image. I'm guessing that will work. Worth trying, anyway.

View solution in original post

2 Replies
johnw
Champion III
Champion III

It's possible that the chart hasn't finished responding to your selections by the time you export. To force it to wait for the changes to complete, use ActiveDocument.GetApplication.WaitForIdle between setting the fields and exporting the image. I'm guessing that will work. Worth trying, anyway.

ob
Partner - Contributor II
Partner - Contributor II
Author

Many thanks! That solved the problem!