c# - 有没有办法在没有事件文档的情况下获取powerpoint幻灯片的宽度和高度?

标签 c# vsto powerpoint

我正在编写一些用于自动发布 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");

最佳答案

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

关于c# - 有没有办法在没有事件文档的情况下获取powerpoint幻灯片的宽度和高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37176647/

相关文章:

c# - 事件处理程序 : What is going on in this code?

c# - 为什么在这种情况下我会打印出 System.char[]?

c# - 如何在 ASP.NET MVC 6 (ASP.NET Core) 中获取 returnUrl AccessDeniedPath

c# - 从功能区按钮访问 Excel 工作表

vba - 如何在[vba] [powerpoint]中为图像添加颜色边框

c# - 执行文件io时如何正确处理异常

excel - 如何在 VSTO 中将值数组分配给 Excel 单元格而不丢失表格格式

C# VSTO : How to block a user from interacting with client (Excel) for a brief period?

c# - 以编程方式生成的 PowerPoint 演示文稿破坏了 PowerPoint 2013

excel - Excel数据与Visio/PPt之间的数据链接