有没有办法在没有活动文档的情况下获取 powerpoint 幻灯片的宽度和高度?

Is there a way to get the width and height of powerpoint slide without active document?

我正在编写一些自动发布 PowerPoint 幻灯片的代码。

我已经发现 PowerPoint 应用程序对象中的 ActiveDocument 让我知道幻灯片的宽度和高度。

但是,当我使用 MsoTriStat.msoFalse 标志启动应用程序时,PowerPoint 当然不会出现在我面前,我无法计算出幻灯片的宽度和高度,因为 Application 没有有任何 ActiveWindow.

那么,还有其他方法可以获取幻灯片的宽度和高度吗?

更新
这是我的测试代码

Application app = new Application();
Presentation presentation = app.Presentations.Add(MsoTriState.msoFalse);
Slide slide = presentation.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);

Console.WriteLine("Shapes in slide: {0}", slide.Shapes.Count);
Console.WriteLine("slide name: {0}", slide.Name);

Console.WriteLine(app.ActivePresentation.Name);

app.ActiveWindow.Width = 1024;
app.ActiveWindow.Width = 768;
app.ActiveWindow.View.Zoom = 100;

presentation.SaveAs(@"C:\Temp\ppt1.pptx");

当您打开一个演示文稿时,它将成为活动演示文稿。 ActivePresentation 对象将使您能够访问所需的属性。

尝试使用 presentation.PageSetup.SlideHeightpresentation.PageSetup.SlideWidth