c# 操作PPT

前段时间要做一个把指定图片放到新建的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;
     

转载于:https://www.cnblogs.com/lcchuguo/p/4049936.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值