c#检测powerpoint的相关属性

 感觉网上有关检测的ppt属性的文章比较少,最近因为工作原因,花了一天时间找到了一些,没有文档的日子真是不好过!
                     
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PowerPoints = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
using ShockwaveFlashObjects;
using Microsoft.Office.Interop.PowerPoint;
namespace PowerPoint
{


    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        //读取ppt的属性
        private void button1_Click(object sender, EventArgs e)
        {

            string filename = @"c:\standard.ppt";

            PowerPoints._Application ap = new PowerPoints.Application();
            //Presentations.Open 第一个参数:文件路径    第二个参数:是否为只读   第三个参数:是否有标题   第四个参数:打开演示文稿而不将它设为可见
            PowerPoints.Presentation ps = ap.Presentations.Open(filename, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);


            //幻灯片
            foreach (PowerPoints.Slide slide in ps.Slides)
            {

                MessageBox.Show("序号" + slide.SlideID.ToString());
                //读取每个幻灯片的备注文本
                foreach (PowerPoints.Shape nodeshape in slide.NotesPage.Shapes)
                {
                    if (nodeshape.TextFrame.HasText.Equals(MsoTriState.msoTrue))
                    {
                        //备注                                      
                        MessageBox.Show("备注" + nodeshape.TextFrame.TextRange.Text);
                    }               

                }


                

                //读取每个幻灯片的每个PowerPoints.DocumentWindow的文本
                foreach (PowerPoints.Shape shape in slide.Shapes)
                {
                    //检测多媒体
                    if (shape.Type == MsoShapeType.msoMedia)
                    {
                        if (shape.MediaType == PpMediaType.ppMediaTypeSound)
                        {
                            MessageBox.Show("音乐");
                        }

                        if (shape.MediaType == PpMediaType.ppMediaTypeMovie)
                        {
                            MessageBox.Show("视频");
                        }
                      
                    }

                    
                    if (shape.Type == MsoShapeType.msoLinkedOLEObject)
                    {
                        MessageBox.Show("图表");
                    }

                    if (shape.Type == MsoShapeType.msoAutoShape)
                    {
                        MessageBox.Show("自选图形");
                    }

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值