[英]Putting all slides of powerpoint presentation into Widescreen mode using C#
[英]Open PowerPoint presentation in slideshow mode - C#
我正在尝试在幻灯片放映模式下直接打开 PowerPoint 演示文稿。 我已经尝试使用进程(如下所示),但是我从 PowerPoint 收到一条错误消息,说它找不到文件,错误消息“PowerPoint 无法读取 C://Users/Route%20Plotter.pptx” . 该问题是由文件名中的空格引起的,因为它在删除时起作用。
string powerPointPath = @"C:\Program Files\Microsoft Office 15\root\office15\powerpnt.exe";
string powerPointFilePath = "\"" + "C://Users/Route Plotter.pptx" + "\"";
Process powerPoint = new Process();
powerPoint.StartInfo.FileName = powerPointPath;
powerPoint.StartInfo.Arguments = " /S " + powerPointFilePath;
powerPoint.Start();
我已经尝试使用 Office 介绍方法(如下),但无法直接在幻灯片模式下打开。
Microsoft.Office.Interop.PowerPoint.Application pptApp = new Microsoft.Office.Interop.PowerPoint.Application();
pptApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
pptApp.Activate();
Microsoft.Office.Interop.PowerPoint.Presentations ps = pptApp.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation p = ps.Open(powerPointFilePath,
Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue)
任何想法如何停止将空格更改为 %20(我已经在路径周围添加引号),或将文件直接打开为幻灯片模式的另一种方法,将不胜感激。
(我使用的是 VS2013 和 PowerPoint 2013)。
感谢 DavidG,问题是斜线的方向。 正斜杠 ( /
) 用于 URI,反斜杠 ( \\
) 用于文件路径。 用反斜杠替换正斜杠可以解决这个问题。
以下代码将用于运行 Power Point 的幻灯片放映模式。 只要你替换文件路径就足够了。
Application ppApp = new Application();
ppApp.Visible = MsoTriState.msoTrue;
Presentations ppPresens = ppApp.Presentations;
Presentation objPres = ppPresens.Open("C:\\Users\\Users\\Documents\\Projects\\LS\\WindowsFormsApp1\\PPT.pptx", MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
Slides objSlides = objPres.Slides;
SlideShowWindows objSSWs;
SlideShowSettings objSSS;
//Run the Slide show
objSSS = objPres.SlideShowSettings;
objSSS.Run();
objSSWs = ppApp.SlideShowWindows;
while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);
//Close the presentation without saving changes and quit PowerPoint
objPres.Close();
ppApp.Quit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.