Reputation: 41
I have an excel that is connected to matlab through active server. I am generating a graph via matlab and export it to excel. However, I need to clear the existing graphs first so it won't overwrite and make a stacked of graphs.
My idea is to find the existing graph first, and clear it. But, so far, I still don't know how to do it.
Anyone knows? I am open to any suggestions.
Thank you so much!
Elizabeth
edit:
this is a matlab script
Excel = actxserver ('Excel.Application');
filename = 'xxx'
invoke(Excel.Workbooks,'Open',filename);
Sheets = Excel.ActiveWorkBook.Sheets;
Sheets.Item('Graphs').Activate;
ActiveSheets = Excel.Activesheet;
plotpie(cost,init_stage)
Shapes = ActiveSheets.Shapes;
ActiveSheets.Shapes.AddPicture('location', 0, 1, 400, 325, 345, 230)
Upvotes: 4
Views: 132
Reputation: 340
Great questions. I can't leave comments so I'll respond here.
Perhaps one of these will work for you.
ActiveSheet.Shapes.Delete
ActiveSheet.DrawingObjects.Delete
ActiveSheet.Pictures.Delete
Upvotes: 1