Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
johnan
Creator III
Creator III

Reload with batfile and macro

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

39 Replies
marcus_sommer

Disable the last option because enabled it will show a popup to agree to the macro execution and the batch couldn't do it.

- Marcus

johnan
Creator III
Creator III
Author

Ah, perfect.

It runs manually, but still the batfile will not close the macrowindow

marcus_sommer

With batch the export worked? And it remains with open module-editor or QV as applications is left open?

- Marcus

johnan
Creator III
Creator III
Author

it remains with open module-editor 

johnan
Creator III
Creator III
Author

Hey all, i tested with QV.exe (8.50) and it works. The only thing now is to save and close the whole QlikView Window.

Can i put this in my bat file in the end?

ActiveDocument.Save
Application.Quit

marcus_sommer

Not in the bat - at the end from the macro.

- Marcus

johnan
Creator III
Creator III
Author

Okay i did that. But i cannot edit the macro any more, it crashes in both QV12 and QV8.50  

suggestions?

marcus_sommer

The quit-statement isn't quite right - it must be:

ActiveDocument.GetApplication.Quit

- Marcus

johnan
Creator III
Creator III
Author

Hahaha, okay i must rebuild the QlikView now. I cant edit anymore 😂

johnan
Creator III
Creator III
Author

Marcus, is this wrong? The qv application will not qiut

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:\inetpub\wwwroot\as400\UTL\Chart_" & chartId & ".png"
ActiveDocument.GetApplication.Quit
end function