Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
bradshields
Partner - Creator
Partner - Creator

export image of sheet as jpg

I want to export an image of the dashboard page as a .jpg!

I have written the following macro


sub Image
call Dashboard
ActiveDocument.Sheets("Dashboard").ExportBitmapToFile "M:\QlikView\BESydney\Latest Dashboard.jpg"
'ActiveDocument.Save
end sub


I call the macro using onpostreload and all works well for a user initiated reload. If I change to OnOpen as the macro trigger the users using server cannot open the model.

This model is however reloaded via a batch file using /r - this results in the image not being exported correctly - the image shows a greyed out image of where the objects are but not the actual guages.

a /l reload works fine but leaves qlikview open and unsaved which is no good for me. the last line of my macro saves the document but it still does not save.

I tried to use an extra line in the batch file to kill Qv.exe using taskkill /IM Qv.exe but the batch stalls because QlikView does not close using /l and thus the taskkill is never executed.

Does anyone have any suggestions?

17 Replies
biester
Specialist
Specialist

Hi,

what does the "call Dashboard" do? If it's QV 9, perhaps it helps to put a "ActiveDocument.GetApplication.WaitForIdle" after this line (or probably - also - after the Export-command). Only today a support guy told me "From my experience I can say that WaitForIdle is always necessary when accessing the sheet object. It seems that delays are occurring there".

Rgds,
Joachim

bradshields
Partner - Creator
Partner - Creator
Author

hi biester

the call Dashboard just calls another sub that opens the dashboard tab and clears any selections.

I will try your suggestions and report back.

Not applicable

We are also facing this problem kindly provide me solution.

It's very very urgent .

Regards

Ashish

Anonymous
Not applicable

Hey,

If you use a Vbscript to do the reload, export and save you should be fine I think. Try the following:

set Qv = CreateObject("QlikTech.QlikView")
Set QvDoc = Qv.OpenDoc ("C:\Document.qvw","user","pass")

QvDoc.Reload
QvDoc.Save

INSERT MACRO HERE TO EXPORT.
USE QvDoc. before calling any APIs

QvDoc.GetApplication.Quit

Save it in a filename.vbs file and run it and it should launch QV, reload Document.qvw, save it and then run any macro stuff you want. Remember you have to call everything with QvDoc.ActiveDocument etc. since the calls are coming from outside QV. It should then quit the application.

Not applicable

Dear Johannes

Thank for your reply but it's not work

We have use this vbs script kindly see it.

It give me error object required:'ActiveDocument'

--------------------------------------------------------------------------------------------------------------------------------------------

set Qv = CreateObject("QlikTech.QlikView")
Set QvDoc = Qv.OpenDoc ("D:\Ashish\Google_analytics\test.qvw","pass")

QvDoc.Reload
QvDoc.Save


Call sendMailFinal()

function sendMailFinal()
'call Dashboard
ActiveDocument.Sheets("Executive_Dashboard").ExportBitmapToFile "D:\Ashish\Google_analytics\Latest_Dashboard.jpg"
'ActiveDocument.Save
end function


QvDoc.GetApplication.Quit

------------------------------------------------------------------------------------------------------------------------------------------

Please help me

Regards

Ashish

Anonymous
Not applicable

Hi Ashish,

As I wrote you need to preceed the command with the name of the QV instance that you've started from the script.

Try:

QvDoc.ActiveDocument.Sheets("Executive_Dashboard").ExportBitmapToFile "D:\Ashish\Google_analytics\Latest_Dashboard.jpg"

Not applicable

Dear Johannes

Thanks for your support it always helping me.

It again given error object doesn't support property or method 'QvDoc.ActiveDocument'

now my script are

set Qv = CreateObject("QlikTech.QlikView")
Set QvDoc = Qv.OpenDoc ("D:\Ashish\Google_analytics\test.qvw","user","pass")
QvDoc.Reload
QvDoc.Save
QvDoc.ActiveDocument.Sheets("Executive_Dashboard").ExportBitmapToFile "D:\Ashish\Google_analytics\Latest_Dashboard.jpg"
QvDoc.GetApplication.Quit

Regards

Ashish

Not applicable

Hi All

I am waiting for your help.

Regards

Ashish

Anonymous
Not applicable

Hi Ashish,

Sorry for the late reply. I totally forgot about this post. Anyway, I missed the syntax a little. You need to drop ActiveDocument as that is your QvDoc. So:
QvDoc.ActiveDocument.Sheets("Executive_Dashboard").ExportBitmapToFile "D:\Ashish\Google_analytics\Latest_Dashboard.jpg"
Should work better.
If an image is not created try adding:
QvDoc.GetApplication.WaitForIdle
before the export statement.

Example script:

set Qv = CreateObject("QlikTech.QlikView")
Set QvDoc = Qv.OpenDoc ("C:\Document.qvw","user","pass")

QvDoc.Reload
QvDoc.Save
QvDoc.GetApplication.WaitForIdle
QvDoc.Sheets("Main").ExportBitmapToFile "C:\Latest_Dashboard.jpg"

QvDoc.GetApplication.Quit