感觉网上有关检测的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("自选图形");
}