Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Delete Object VBS

Hello,

I created a table with some random Dimension and Expression

Set Table = ActiveDocument.ActiveSheet.CreateStraightTable

Table.AddDimension ("Title"&Suffix)

Table.AddExpression ("[Current State"&Suffix&"]")

.

Now, when I want to use filters to order by some criteria, I want to rebuild everything the table like I did before, but with CreateStraightTable, it will generate again a new table and I want to drop the old table.

I thought about doing :

Set the_table = ActiveDocument.GetSheetObject("Table")         // Where Table is the name from my current Sheet.

the_table.Cut

or:

the_table.Remove

or:

the_table.DeleteObject()

But none of those are working.

Could someone give me a hint?

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Hello,

Thanks for the quick reply.

It deletes all Objects from the Sheet.

But with a bit of adaptation I figured out the rest and this link:

http://community.qlik.com/thread/3177

'Delete Previous Chart

rem ** remove one sheet object on sheet Main **

set s=ActiveDocument.Sheets("Main")

orignumber=s.NoOfSheetObjects

for i=0 to orignumber-1

     rem ** get unique object ID for given object on sheet **

     set so = s.SheetObjects(i)

     id = so.GetObjectId

     'Prints all objects ids on the current sheet

     'msgbox("ID = " & id)

     'Prints Table ID

     IF id = "Document\Table" THEN

         'TableBox to be deleted

         s.SheetObjects(i).Close

     END IF

next

View solution in original post

2 Replies
Gysbert_Wassenaar

You need to use the close() member:

rem ** remove all sheet objects on sheet Main **

set s=ActiveDocument.Sheets("Main")

orignumber=s.NoOfSheetObjects

for i=0 to orignumber-1

    s.SheetObjects(0).Close

next


talk is cheap, supply exceeds demand
Not applicable
Author

Hello,

Thanks for the quick reply.

It deletes all Objects from the Sheet.

But with a bit of adaptation I figured out the rest and this link:

http://community.qlik.com/thread/3177

'Delete Previous Chart

rem ** remove one sheet object on sheet Main **

set s=ActiveDocument.Sheets("Main")

orignumber=s.NoOfSheetObjects

for i=0 to orignumber-1

     rem ** get unique object ID for given object on sheet **

     set so = s.SheetObjects(i)

     id = so.GetObjectId

     'Prints all objects ids on the current sheet

     'msgbox("ID = " & id)

     'Prints Table ID

     IF id = "Document\Table" THEN

         'TableBox to be deleted

         s.SheetObjects(i).Close

     END IF

next