gpt4 book ai didi

c# - 如何更改从 PowerPoint 的 c# 加载项显示的当前幻灯片

转载 作者:行者123 更新时间:2023-11-30 15:28:05 24 4
gpt4 key购买 nike

我正在尝试使用 c# 插件来控制 PowerPoint 当前幻灯片(从红外 Remote 双向滑动),但我卡在了 power point 插件的编程部分

就这么简单,我有一个无限循环等待后台线程上的串行命令(完成这部分),但我卡在如何更改当前显示的幻灯片上

我正在使用 Office 加载项 -> Power Point 2013 加载项

最佳答案

如何更改当前显示的幻灯片?

Microsoft.Office.Interop.PowerPoint.Application objPPT;
Microsoft.Office.Interop.PowerPoint.Presentations objPresentations;
Microsoft.Office.Interop.PowerPoint.Presentation objCurrentPresentation;
Microsoft.Office.Interop.PowerPoint.SlideShowView objSlideShowView;

private void StartPowerPointPresentation(object sender, EventArgs e)
{
// Open an instance of PowerPoint and make it visible to the user
objPPT = new Microsoft.Office.Interop.PowerPoint.Application();
objPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;

//Open a presentation
OpenFileDialog openDlg = new OpenFileDialog();
openDlg.Filter = "Powerpoint|*.ppt;*.pptx|All files|*.*";
if (opendlg.ShowDialog() == true)
{
//Open the presentation
objPresentations = objPPT.Presentations;
objCurrentPresentation = objPresentations.Open(openDlg.FileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
//Hide the Presenter View
objCurrentPresentation.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
//Run the presentation
objCurrentPresentation.SlideShowSettings.Run();
//Hold a reference to the SlideShowWindow
objSlideShowView = objCurrentPresentation.SlideShowWindow.View;
}
}

private void ShowNextSlide(object sender, EventArgs e)
{
//Unless running on a timer you have to activate the SlideShowWindow before showing the next slide
objSlideShowView.Application.SlideShowWindows[1].Activate();
//Go to next slide
objSlideShowView.Next();
}

这在 AddIn 中应该很容易实现,您可能需要在 StartUp 事件中连接一些事件,然后按照此示例了解如何使用对象模型来显示下一张幻灯片。

关于c# - 如何更改从 PowerPoint 的 c# 加载项显示的当前幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26376639/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com