当前位置:首页 > 随心手记 > 个人笔记

C# 操作PowerPoint

博主6年前 (2020-07-20)个人笔记5269


u=3558142891,1024264363&fm=26&gp=0.jpg

最近想做一个小东西,打算将ppt和视频结合在一起。所以研究起了powerpoint。

   首先,环境是vs2008,vs2019,office我用的是2016(.ppt,.pttx 都可以)。

   接下来,是如果调用PowerPoint,建一个c#的控制台应用程序,然后右键解决方案资源管理器里的引用-》添加引用-》浏览:找到office安装路径 下有个OFFICE14,找到msppt.olb

例如D:\Program Files\Microsoft Office\Office14;找到后添加进去,引入框中便会多出几个接口Microsoft.Office.Interop.PowerPoint和Microsoft.Office.Core。然后在程序中添加引用。

程序列子:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;

namespace tst
{
    class Program
    {
        static void Main(string[] args)
        {
            //   Purpose:   Creates   a   PowerPoint   presentation,
            //   adds   a   slide   and   two   shapes   to   the   slide,
            //   animates   the   shapes,   and   runs   the   slide   show.

>> 点击阅读全文
《C# 操作PowerPoint》.docx
将本文下载保存,方便收藏和打印
导出文档

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。