Reputation: 23
I'm writing some code for automatically publishing PowerPoint slides.
I'v already found that ActiveDocument
in PowerPoint application object allow me to know width and height of slides.
However, When I start the application with MsoTriStat.msoFalse
flag, PowerPoint doesn't appear to me of course and I can't figure out width and height of slide because Application
doesn't have any ActiveWindow
.
So, is there another way to get width and height of slide?
UPDATE
Here is my test code
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");
Upvotes: 2
Views: 2565
Reputation: 99
Try using presentation.PageSetup.SlideHeight
and presentation.PageSetup.SlideWidth
Upvotes: 3
Reputation: 14809
When you open a presentation it becomes the active presentation. The ActivePresentation object will give you access to the properties you need.
Upvotes: 0