Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi , i have a macro that export images, when i run this in the qlikview with a button it works perfect.
When i run this with a batfile, it's reloading the qv but the last thing happend is that the macrowindows stays open and nothing more happens.
Batfile:
"C:\Program Files\QlikView\Qv.exe" /l /NoSecurity "C:\Qv\MXXX.qvw"
Macro:
function exportImages
' Test if export should be made
set v = ActiveDocument.Variables("RunNow")
if v.GetContent.String = "Yes" then
v.SetContent "No",true
exportAll
ActiveDocument.GetApplication.Quit
end if
end function
function exportAll
export("CH01")
export ("TX01")
end function
function export(chartId)
set obj = ActiveDocument.GetSheetObject(chartId)
obj.ExportBitmapToFile "C:\UTL\Chart_" & chartId & ".png"
end function
What can i do to get this working?
Br
It shouldn't - the batch creates a new instance and QV quit it again. It should work in this way.
By testing such things you need further ensure that no other instance has opened the same file and/or that further files are opened within the instance - to avoid the classical windows popup's if you want to overwrite this file or store the other or similar things because these popup's are there but won't be displayed in any way.
- Marcus
Try it in this way:
sub exportImages
' Test if export should be made
set v = ActiveDocument.Variables("RunNow")
if v.GetContent.String = "Yes" then
v.SetContent "No",true
call exportAll
ActiveDocument.GetApplication.Quit
end if
end sub
sub exportAll
call export("CH01")
ActiveDocument.GetApplication.Sleep 1000
call export ("TX01")
end sub
sub export(chartId)
set obj = ActiveDocument.GetSheetObject(chartId)
obj.restore
ActiveDocument.GetApplication.WaitForIdle
obj.ExportBitmapToFile "C:\UTL\Chart_" & chartId & ".bmp"
end sub
The grey statements are optional - especially in larger export-routines they are necessary to ensure a stable workflow.
- Marcus
Okay, i will try.
To call the macro is exportAll?
Yes, exportAll - the essential point is the switch from a function to a sub because a function couldn't be "called" and it expect a return-value. The call itself is optional but it improved the readability.
- Marcus
It's the same, it will open the macromodule at the end 😞
And it works when i open it manually and press the button
Something else that i missing?
Hi!
Can you please share a screenshot of the macro module when it opens when you run it from the bat file, please?
Jaime.
Yes, here you go!
What do you mean with?
"... And it works when i open it manually and press the button ..."
Right click on the object and exporting it, executing it within the module-editor, from the UI per button/action, from the outside per EXECUTE or windows task, ...?
- Marcus
I have a button on the QV application. In that button i have call run Macro -> exportAll.
So if i open the QV manually and press that button it's work.
If i run the batfile, after the reload it's just open the Macrowindow and nothing happens.
Quite weird, can not reproduce your problem.
Got to ask: have you configured a trigger "on open" as in the following image?
BTW, shouldm't you call "exportImages" instead of "exportAll"?
On the other hand, when the macro is run from the bat file, is it run with a user with writting permissions in "C:\UTL\"?
Regards,
Jaime.