简体   繁体   中英

How to delete a specified row from a Powerpoint table using Microsoft Office Interop with C#

Is it possible to delete any row from a Powerpoint table using office Interop with C#??

PowerPoint.Application objApp;
PowerPoint.Presentations objPresSet;
PowerPoint._Presentation objPres;
PowerPoint.Slides objSlides;
PowerPoint._Slide objSlide;
PowerPoint.TextRange objTextRng;
PowerPoint.Table objTable;

objApp = new PowerPoint.Application();

//objApp.Visible = MsoTriState.msoTrue;

objPresSet = objApp.Presentations;
objPres = objPresSet.Open(strTemplate,
MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
objSlides = objPres.Slides;
objSlide = objSlides[1];

for (int i=0;i<5;i++)
{
    objTable.Rows.Add(objTable.Rows.Count);
{           

// How to delete any rows ???

`

The Rows collection in PowerPoint is somehow strange, ie to delete a row you have to tell the row to delete itself. This means that you have to use the Delete() method on a row (you can obtain it as a result from Add , or using the Item[] property on the Rows collection).

Be careful that Delete raise an exception when you try to delete a row that is the only one in the Table. In these situation you should delete the Table instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM