1

I Have a requirement to add a OnClick action to Shape object in Micro Soft Power Point Addin for Office 2010 and above which is built using C# language. There are events like

SlideSelectionChanged

WindowBeforeRightClick

Which doesn't work as needed, Right Click Event doesn't even work on the Shape Objects.

Is there a way to subscribe to such type of events, I would not prefer to use MACRO however if that is inevitable I will use it.

Sadanand
  • 107
  • 2
  • 11
  • Recently here was the similar question. [Maybe it can help you](http://stackoverflow.com/a/34907714/1295010). It was about excel, but many API's are the same over MS Office products. – Alex Butenko Jan 22 '16 at 20:09

1 Answers1

0

This solution would work.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        this.Application.WindowSelectionChange += OnWindowSelectionChanged;
    }

void OnWindowSelectionChanged(PowerPoint.Selection Sel)
    {
        if (Sel.Type == PowerPoint.PpSelectionType.ppSelectionShapes)
        {
             PowerPoint.ShapeRange shapeRange = Sel.ShapeRange;
             //Do some work
        }
    }

private void ThisAddIn_ShutDown(object sender, System.EventArgs e)
    {
        this.Application.WindowSelectionChange -= OnWindowSelectionChanged;
    }

It's Good to have some flag to make sure you are doing the needful only on desired Shape Objects by setting some flag by using AltText like

if (Sel.ShapeRange.AlternativeText.Contains("SomeFlag"))
   {
      //Do some thing
   }
Sadanand
  • 107
  • 2
  • 11