4

PowerPoint 用のアドインを作成していて、Slides または Slide オブジェクト、あるいはプレゼンテーション全体にアクセスする必要があります。残念ながら、これを行う唯一の方法は、新しいppt ファイルを開くことです。現在、私は現在のプレゼンテーションを保存し、それを Packaging で再度開いて何かを操作するというハックな方法に頼らなければなりません (より具体的には、pptx ファイルから Slide オブジェクトを SHA して、それらが変更されたかどうかを確認する必要があります --理想的ではありません)

ファイルを IO することなく、現在 PowerPoint で開いているファイルを開く方法はありますか?

助けてくれてありがとう、P

4

1 に答える 1

0

VisualStudio で PowerPoint (2007/2010) アドイン プロジェクトを作成したとします。Globals一般に、次の方法で静的クラスを使用してアクティブなプレゼンテーションにアクセスできます。

Globals.ThisAddIn.Application.ActivePresentation.Slides[slideIndex] ...

編集:使用例:

using PowerPoint = Microsoft.Office.Interop.PowerPoint;

...

try
{
    int numberOfSlides = Globals.ThisAddIn
        .Application.ActivePresentation.Slides.Count;

    if (numberOfSlides > 0)
    {
        // get first slide
        PowerPoint.Slide firstSlide = Globals.ThisAddIn
            .Application.ActivePresentation.Slides[0];

        // get first shape (object) in the slide
        int shapeCount = firstSlide.Shapes.Count;

        if (shapeCount > 0)
        {
            PowerPoint.Shape firstShape = firstSlide.Shapes[0];
        }

        // add a label
        PowerPoint.Shape label = firstSlide.Shapes.AddLabel(
                Orientation: Microsoft.Office.Core
                   .MsoTextOrientation.msoTextOrientationHorizontal,
                Left: 100,
                Top: 100,
                Width: 200,
                Height: 100);

        // write hello world with a slidenumber
        label.TextFrame.TextRange.Text = "Hello World! Page: ";
        label.TextFrame.TextRange.InsertSlideNumber();
    }
}
catch (Exception ex)
{
    System.Windows.Forms.MessageBox.Show("Error: " + ex);

}
于 2012-10-02T10:32:35.450 に答える