用C#打开一个PPT并修改背景图片
lyp88 2009-04-11 09:13:05 //下面这句老是出问题 我不知道问题出在哪儿? 希望能帮我解决 我要实现的功能是 通过程序打开一个PPT 然后自动修改PPT的背景图 pp.Slides.Application.ActiveWindow.Selection.SlideRange.Background.Fill.UserPicture(@"C:\Documents and Settings\Administrator\桌面\博研360.jpg");
以下是详细代码: 需要整个项目的可以加我QQ:54540387
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.PowerPoint;
namespace WindowsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.PowerPoint.ApplicationClass pa;
Microsoft.Office.Interop.PowerPoint.Presentation pp;
pa = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
pp = pa.Presentations.Open(@"G:\项目\博研\测试.ppt", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse);
Microsoft.Office.Interop.PowerPoint.TextRange oText;
int slideCount = pp.Slides.Count;//总的幻灯片数
//下面这句老是出问题 我不知道问题出在哪儿? 希望能帮我解决 我要实现的功能是 通过程序打开一个PPT 然后自动修改PPT的背景图
pp.Slides.Application.ActiveWindow.Selection.SlideRange.Background.Fill.UserPicture(@"C:\Documents and Settings\Administrator\桌面\博研360.jpg");
label1.Text = slideCount.ToString();
pp.SaveAs(@"G:\项目\博研\测试2.ppt", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPowerPoint7, Microsoft.Office.Core.MsoTriState.msoTrue);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}