Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This example shows how to call a macro that saves image files for a selected sheet and chart to a specified location on reload.
The saved images could then be published via a web site or Wall Board, for example.
This QlikView was written in response to a post in the QlikView UK user group.
For other tutorial apps you can download and use, please see:
https://www.quickintelligence.co.uk/qlikview-examples/
Hope you find this app useful.
Steve Dark
Hi Steve,
thanks for the exmaple. I adapted your macro to my application.
I just ran into a new Problem: I want to export/save more Graphics, but the code always stops after 24 items.
Do you have an idea for this topic??
Would be great,
Hi Tobias,
Thanks for feeding back that this macro is working for you. I've not hit that issue - but then I have not tried to export that many items.
Is the number of items variable - eg. if you export simpler items (eg. Text Areas) can you get more out? This would imply some kind of time out.
Can you try creating multiple macros - perhaps one per sheet - and then firing each macro one after the other in a chain of Actions. This may allow you to export all that you need to?
Hope that helps.
Steve
The macro code used in this example is as follows:
public function ExportImage
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetSheetByID("DASH").Activate
vFolder = ActiveDocument.GetVariable("vExportFolder").GetContent().String
set obj = ActiveDocument.GetSheetByID("DASH")
ActiveDocument.GetApplication.WaitForIdle
fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"
ActiveDocument.GetApplication.WaitForIdle
obj.ExportBitmapToFile vFolder & fileName
set obj = ActiveDocument.GetSheetObject("EXPORT")
ActiveDocument.GetApplication.WaitForIdle
fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"
ActiveDocument.GetApplication.WaitForIdle
obj.ExportBitmapToFile vFolder & fileName
end function
You will need to modify the code to match the object name of the object which you wish to export.
Regards,
Steve
Hi Steve,
i got it. As you suggested I split up the Code in pieces. It is more comfortable to adjust in case of changes in the document. now it works fine.
THanks again,
Tobias
No worries, glad it now works.
- Steve
hi,
while exporting image in mail body, i didn't get image outside border.
can u suggest how to get outside border of image in mail body....
The missing border and (sometimes more of an issue) the caption of a chart happens whether you export the chart through the UI, copy and paste it or even pull it into a QlikView report.
If you need to get a border on there you could potentially post process the image with a graphics package that accepts a command line parameter. This could then be called from the macro using a CMD function call?
What are you then pulling the image in to? If it is going into a web page, for example, you could then put the border back on using HTML?
Hope that helps,
Steve
thnx 4 d help...
but i got the solution in qlikview user prefe. setting itself....
Sorry, I forgot that that had been added to the Export tab of the User
Preferences. There was a time when this wasn't an option.
Glad you sorted it.
- Steve
Steve
I found this to be very helpful, but was not sure if it was working until I examined the code. As a result, I added a message box at the bottom of your code below. Do you know if QlikView has automation/OLE links to print this example if you are not in the QlikView application? Thanks again
public function ExportImage
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetSheetByID("DASH").Activate
vFolder = ActiveDocument.GetVariable("vExportFolder").GetContent().String
set obj = ActiveDocument.GetSheetByID("DASH")
ActiveDocument.GetApplication.WaitForIdle
fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"
ActiveDocument.GetApplication.WaitForIdle
obj.ExportBitmapToFile vFolder & fileName
set obj = ActiveDocument.GetSheetObject("EXPORT")
ActiveDocument.GetApplication.WaitForIdle
fileName = "ExportScreen_" & replace(replace(replace(date() & "_" & time(), "/", ""), ".", ""), ":", "") & ".png"
ActiveDocument.GetApplication.WaitForIdle
obj.ExportBitmapToFile vFolder & fileName
message=msgbox(vFolder & fileName,0,"Export Image sent to...")
end function