Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am trying unsuccessfully to export a chart into jpg file.
In the macro I wrote:
FUNCTION ExportObjetToJpg (ObjID,FName)
ActiveDocument.GetSheetObject(ObjID).ExportBitmapToFile Fname
In the Script section I called the macro:
Let var1=ExportObjectToJpg("CH57","C:\Bi\Dev\SalesGen.jpg")
The qv file attached
Thanks
HI,
Here you are:
FUNCTION ExportObjectToJpg( ObjID, fName)
ActiveDocument.GetSheetObject(ObjID).ExportBitmapToFile fName
END FUNCTION
sub gonza
rem *** This method is not meaningful for all types of sheet objects ***
set obj = ActiveDocument.GetSheetObject("CH57")
obj.ExportBitmapToFile "c:\Image.jpg"
end sub
BR//Gonza
This isn't possible because while a script-execution exists no ActiveDocument or a GUI - therefore any access on such objects will be failed. You could only open your app from outside per batch or vbs and execute your export with any trigger or directly, examples:
Open + Reload per Batch (bat- or cmd-file):
\\QVSERVER\d\QlikView\Client\QV.exe /r "\\ QVSERVER \d\Qlikview\Reports\MyApp.qvw"
Open + Export per vbs:
sub export
dim doc, newApp, newdoc, ex
set doc = ActiveDocument
set newApp = ActiveDocument.GetApplication
set newdoc = newApp.OpenDoc (path.Text & "\" & app.Text,"","")
set ex = newdoc.GetSheetObject("CH172")
ex.Activate
ex.maximize
ex.ExportBitmapToFile path & "Gesamt " & datum & ".bmp"
ex.minimize
newdoc.closedoc
doc.GetApplication.Quit
end sub
- Marcus
Hi,
Thanks for the answers, Gonzalo - I couldn't manage to get the jpg file
and Marcus I don't know vb script (do I run them as .bat extension?)
but I used the trigger on Post Reload instead from here: http://community.qlik.com/docs/DOC-4315
However now I have to use the macro for each month selected (30 times),
Is it possible to change 'current selection' from the script (and run with a loop)?
Thanks again.
I use for such things (reloading, exports) a (per windows scheduler triggered) qvw-file with a Post-Reload-Trigger which the target-qvw's opened and reload, exports and so on. A loop through field-values is possible - have a look on the changed script. How it worked and for further possibilities look in APIGuide.qvw in your install-folder.
sub export
dim doc, newApp, newdoc, ex
dim lbaw, valueOne
set doc = ActiveDocument
set newApp = ActiveDocument.GetApplication
set newdoc = newApp.OpenDoc (path.Text & "\" & app.Text,"","")
set lbaw = ActiveDocument.GetSheetObject("LB09")
valueOne = lbaw.GetPossibleValues
set ex = newdoc.GetSheetObject("CH172")
ex.Activate
ex.maximize
for i_One = lbound(valueOne) to ubound(valueOne)
valueSelection = valueOne(i_One)
newdoc.Fields("YourField").Select(valueSelection)
newdoc.GetApplication.WaitForIdle
ex.ExportBitmapToFile path & "Gesamt " & datum & ".bmp"
next
ex.minimize
newdoc.closedoc
doc.GetApplication.Quit
end sub
- Marcus