前段时间要做一个把指定图片放到新建的ppt的东西,在网上找了点资料看了一下,发现用C#做好像是最简单的一个,一下是在网上找的一段代码,直接贴进去就能够执行,可是在执行之前一定要加入dll支持:
项目->加入引用->com->microsoft
office object libraty
项目->加入引用->com->microsoft
powerpoint object libraty
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.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Graph = Microsoft.Office.Interop.Graph;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
public
partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void button1_Click(object sender, System.EventArgs e)
{
ShowPresentation();
GC.Collect();
}
private
void ShowPresentation()
{
String
strTemplate, strPic;
strTemplate
=
"C:\Program
Files\Microsoft Office\Templates\Presentation Designs\Blends.pot";
strPic
= "C:\Windows\Blue Lace 16.bmp";
bool
bAssistantOn;
PowerPoint.Application
objApp;
PowerPoint.Presentations
objPresSet;
PowerPoint._Presentation
objPres;
PowerPoint.Slides
objSlides;
PowerPoint._Slide
objSlide;
PowerPoint.TextRange
objTextRng;
PowerPoint.Shapes
objShapes;
PowerPoint.Shape
objShape;
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.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Graph = Microsoft.Office.Interop.Graph;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{