S
SSonii
Guest
How to get element (shape ) in chart that is selected (clicked ) by mouse by user .I want to change color of selected element ,but every time what i am getting in shapeRange is "placeholder".
last thing what i tried is
ColorStyle colorstyle2 = MyAddin.AddinModule.CurrentInstance.SelectedColorStyle;
int setColor = ColorTranslator.ToOle(System.Drawing.Color.FromArgb(colorstyle2.R, colorstyle2.G, colorstyle2.B));
int position = app.ActiveWindow.Selection.ShapeRange.ZOrderPosition;
Slide slide2 = (Slide)app.ActiveWindow.View.Slide;// SELECTS CHART FROM SHAPE RANGE AS SELECTION HAS SHAPERANGE not shape
powerPoint.Shape s = slide2.Shapes[position];
if (s.HasChart==MsoTriState.msoTrue)
{
object cht = s.GetType().InvokeMember("Chart", BindingFlags.GetProperty, null, (object)s, null);
object chtFormat = cht.GetType().InvokeMember("Format", BindingFlags.GetProperty, null, (object)cht, null);
object chtFill = cht.GetType().InvokeMember("Fill", BindingFlags.GetProperty, null, (object)chtFormat, null);
object chtBackcolor = chtFill.GetType().InvokeMember("Backcolor", BindingFlags.GetProperty, null, (object)chtFill, null);
object[] args = { setColor };//also used {0} here
object chtRGB = chtBackcolor.GetType().InvokeMember("RGB", BindingFlags.SetProperty, null, (object)chtBackcolor, args);
}
But it does nothing !
Continue reading...
last thing what i tried is
ColorStyle colorstyle2 = MyAddin.AddinModule.CurrentInstance.SelectedColorStyle;
int setColor = ColorTranslator.ToOle(System.Drawing.Color.FromArgb(colorstyle2.R, colorstyle2.G, colorstyle2.B));
int position = app.ActiveWindow.Selection.ShapeRange.ZOrderPosition;
Slide slide2 = (Slide)app.ActiveWindow.View.Slide;// SELECTS CHART FROM SHAPE RANGE AS SELECTION HAS SHAPERANGE not shape
powerPoint.Shape s = slide2.Shapes[position];
if (s.HasChart==MsoTriState.msoTrue)
{
object cht = s.GetType().InvokeMember("Chart", BindingFlags.GetProperty, null, (object)s, null);
object chtFormat = cht.GetType().InvokeMember("Format", BindingFlags.GetProperty, null, (object)cht, null);
object chtFill = cht.GetType().InvokeMember("Fill", BindingFlags.GetProperty, null, (object)chtFormat, null);
object chtBackcolor = chtFill.GetType().InvokeMember("Backcolor", BindingFlags.GetProperty, null, (object)chtFill, null);
object[] args = { setColor };//also used {0} here
object chtRGB = chtBackcolor.GetType().InvokeMember("RGB", BindingFlags.SetProperty, null, (object)chtBackcolor, args);
}
But it does nothing !
Continue reading...