Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

scottwadeson
Not applicable

Deleting objects using a macro

Hi,

I am trying to create a macro that deletes a list of Qlikview objects.

I already have a variable, called vOriginalObjects2, which creates a list of objects to be deleted, but the below macro only seems to delete a large chunk of them. I feel like the error is at the point where i'm saying 'for each object' and this isn't actually looking at all the objects in the list?

The variable vOriginalObjects2 contains a long list of objects such as:

Document\AnalysisBar,Document\AnalysisBubble,Document\DashTrellis3,Document\DashTrellis4,Document\TX29,Document\TX30...

And the macro is:

Sub DeleteOriginalObjects

set s=ActiveDocument.Sheets("Main")

vArray = ActiveDocument.GetVariable("vOrigObjects2").GetContent.String

chartArray =split(vArray, ",")

For each object in chartArray

s.SheetObjects(object).Close

Next    

End Sub

Does anyone know where I am going wrong?

To provide a bit of context, the reason I am doing this is so I can easily find out which objects have been added to a qlikview document since the initial version. I have the list of objects from the initial version (vOriginalObjects2) and the plan is to delete all of these using the macro, then press ctrl+shift+s to see what is left.

Thanks!

Scott

Tags (1)
1 Solution

Accepted Solutions
scottwadeson
Not applicable

Re: Deleting objects using a macro

FYI - I've realised what the problem was...

The macro was stopping where an initial sheet object no longer exists.

Adding 'On Error Resume Next' before the line 's.SheetObjects(object).Close' solves this 

1 Reply
scottwadeson
Not applicable

Re: Deleting objects using a macro

FYI - I've realised what the problem was...

The macro was stopping where an initial sheet object no longer exists.

Adding 'On Error Resume Next' before the line 's.SheetObjects(object).Close' solves this