Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
scottwadeson
New Contributor II

Deleting multiple 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 (2)
1 Solution

Accepted Solutions
scottwadeson
New Contributor II

Re: Deleting multiple 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
New Contributor II

Re: Deleting multiple 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 

Community Browser