11,578 questions
Slide.Export() closes PowerPoint menus when it is called
Кирилл Приходько
1
Reputation point
I am developing a VSTO add-in for PowerPoint, where every 5 seconds a slide that is currently selected needs to be saved as image. The code looks like this:
public partial class ThisAddIn
{
public Form form = new Form
{
Opacity = 0.01,
Visible = false,
};
delegate void InvokeEventHandler();
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
form.Show();
var del = new InvokeEventHandler(() => Timer_Tick());
form.Invoke(del);
var timer = new System.Windows.Forms.Timer();
timer.Interval = 5000;
timer.Tick+= (s, ea) => form.Invoke(del);
timer.Start();
}
private void Timer_Tick()
{
try
{
var slide = (Slide)Application.ActiveWindow.View.Slide;
slide.Export(Path.Combine(Path.GetTempPath(), "test"), "png");
}
catch
{
return;
}
}
}
This code works, but unfortunately every time the timer ticks (specifically, every time Slide.Export() is called), it looks like PowerPoint window freezes for a split second, and all expanded menus get closed. For example, if you open the right-click menu on any slide and wait for 5 seconds, it will close once the timer ticks.
Is there any way to fix this?
Thanks
Developer technologies | C#
Sign in to answer