//下面这句老是出问题 我不知道问题出在哪儿? 希望能帮我解决 我要实现的功能是 通过程序打开一个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)
{ }
}
}
以下是详细代码: 需要整个项目的可以加我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)
{ }
}
}
{
Microsoft.Office.Interop.PowerPoint.ApplicationClass pa;
Microsoft.Office.Interop.PowerPoint.Presentation pp;
pa = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
try
{ pp = pa.Presentations.Open(@"C:\Downloads\遗传算法.ppt", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse);
pa.Activate();
pp.NewWindow();
//pp = pa.Presentations.OpenOld(@"C:\Downloads\遗传算法.ppt", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse);
int slideCount = pp.Slides.Count;//总的幻灯片数
//pp.Slides.Application.ActiveWindow.Selection.SlideRange.Background.Fill.UserPicture(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\large_2668o107.jpg");
//pp.SlideShowWindow.Application.ActiveWindow.Selection.SlideRange.Background.Fill.UserPicture(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\large_2668o107.jpg");
pp.Application.ActiveWindow.Selection.SlideRange.Background.Fill.UserPicture(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\large_2668o107.jpg");
//pp.Windows.Application.ActiveWindow.Selection.SlideRange.Background.Fill.UserPicture(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\large_2668o107.jpg");
//pp.SlideShowWindow.Application.ActiveWindow.Selection.SlideRange.Background.Fill.UserPicture(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\large_2668o107.jpg");
label1.Text = slideCount.ToString();
pp.SaveAs(@"C:\Downloads\遗传算法1.ppt", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPowerPoint7, Microsoft.Office.Core.MsoTriState.msoTrue);
pp.Close();
pa.Quit(); }
catch
{
//MessageBox.Show("NO"); }
}打开了,也另存为了,就是没有改背景,哎