C# PPT 查找替换

public void ReplaceAll(string OldText,string NewText)
        {
            int num = PageNum();
            for (int j = 1; j <=num; j++)
            {
              POWERPOINT.Slide   slide = objPresSet.Slides[j];
                for (int i = 1; i <=slide.Shapes.Count; i++)
                {
                    POWERPOINT.Shape shape = slide.Shapes[i];
                    if (shape.TextFrame != null)
                    {
                        POWERPOINT.TextFrame textFrame = shape.TextFrame;
                        try
                        {
                            if (textFrame.TextRange != null)
                            {
                                textFrame.TextRange.Replace(OldText, NewText);
                            }
                        }
                        catch
                        { }
                    }
                }
            }
        }

private void button3_Click(object sender, EventArgs e)
        {
            OperatePPT pOperatePPT = new OperatePPT();
            pOperatePPT.PPTOpen(this.textBox1.Text);
            pOperatePPT.ReplaceAll("闫磊", "闫磊\r\nEmail:gisworld@126.com");
        }

上一篇:[转]Vim 复制粘贴探秘


下一篇:Sharepoint学习笔记—习题系列--70-576习题解析 -(Q36-Q39)