Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys, I need help with a QlikView macro that deletes all objects below a line as in the screenshot below. When the 'Delete Objects' button is clicked, a macro should run that deletes all the objects below the line. It should be dynamic, that means if there are any other tables or charts below this line they all should also be deleted aswell, so no hardcoding of object IDs should be used in the macro, the logic should be dynamic like delete all objects below the Y-pos = 168 (line position). Please find the example qvw file attached
Any help is greatly appreciated?
Thanks
I tried using the below macro (Also please see this macro in the attached qvw):
Sub DeleteObjectsNew
set s=ActiveDocument.ActiveSheet
orignumber=s.NoOfSheetObjects
for i=0 to orignumber-1
set obj = s.SheetObjects(i)
pos = obj.GetRect.Top
if ( pos > 168) then
s.SheetObjects(i).Close
end if
next
End SUB
But this is not working as expected. When I clicked the Delete Objects button, its opening the macro editor, which when I closed shows that some objects were deleted. I had to repeat this a few times to get all the objects deleted.
Any thoughts on how to tweak this code to make it work correctly?
Thanks
This is most likely a timing issue, look at the WaitForIdle API, if you put that between each loop, it may work consistently, I believe the underlying issue is the calculation engine and the API fighting over things, the API I mentioned will pause things allowing the Calc engine to recalc before the next iteration occurs, will likely slow things down too, just FYI, but if I am correct, it should get things to run all the way through I believe.
Regards,
Brett