I have created an Office add-in in which I need to add a slide to the presentation on click of a custom button.
Now, if the user clicks at the top(before first slide) in slide preview pane(i.e pane in the left hand side), the new custom slide should be added at the first position. If however, the user selects in between any two slides, the new custom slide should be added in between.
I am trying the below code:
if (insertNextSlideHere == 0)
{
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
}
else if (Globals.ThisAddIn.sldIndexVal == 0 && Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex == 1)
{
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
slide.MoveTo(1);
}
else if (Globals.ThisAddIn.sldIndexVal == 0 && Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex > 1)
{
MessageBox.Show("loop1");
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex + 1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
}
else if (Globals.ThisAddIn.sldIndexVal == 0)
{
MessageBox.Show("loop2");
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
slide.MoveTo(2);
}
else
{
MessageBox.Show("loop3");
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex +1,
Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
}
However, I am basically not able to figure out how to distinguish between when the mouse is clicked at the top and when in between two slides.
Please refer to the image attached and help.) Thanks!