public void TrialButtonClk(Office.IRibbonControl control)
{
//to get the slideID
int slideId =
Globals.ThisAddIn.Application.ActiveWindow.Selection.SlideRange.SlideID;
//get the slide using the slideID and then query for its index
int slideindex =
Globals.ThisAddIn.Application.ActivePresentation.Slides.FindBySlideID(slideId).SlideIndex;
//to set the powerpoint presentation to a certain slide use the
slideindex obtained by the slideID
Globals.ThisAddIn.Application.ActiveWindow.View.GotoSlide(slideindex);
//set up the presentation
PowerPoint.Presentation presentation =
Globals.ThisAddIn.Application.ActivePresentation;
//set up slide
PowerPoint.Slide slide =
Globals.ThisAddIn.Application.ActivePresentation.Slides[slideindex];
PowerPoint.Shape text =
slide.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 100, 25);
text.TextFrame.TextRange.Text = "Hello";
//PowerPoint.Shape t1 =
slide.Shapes.AddDiagram(Microsoft.Office.Core.MsoDiagramType.msoDiagramOrgChart, 50,50,50,50);
//t1.AutoShapeType =
Microsoft.Office.Core.MsoAutoShapeType.msoShapeChord;
//t1.DiagramNode.AddNode(Microsoft.Office.Core.MsoRelativeNodePosition.msoAfterNode, Microsoft.Office.Core.MsoDiagramNodeType.msoDiagramAssistant);
//PowerPoint.Shape t2 = slide.Shapes.
//t1.Diagram.AutoFormat =
Microsoft.Office.Core.MsoTriState.msoTrue;
//t1.Diagram.AutoLayout =
Microsoft.Office.Core.MsoTriState.msoTrue;
//t1.Fill.BackColor.ObjectThemeColor =
Microsoft.Office.Core.MsoThemeColorIndex.msoThemeColorAccent1;
//t1.Diagram.Type =
Microsoft.Office.Core.MsoDiagramType.msoDiagramOrgChart;
//t1.TextFrame.TextRange.Text = "hey";
//PowerPoint.Shape text =
slide.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 100, 100, 100, 25);
//t1.Fill.ForeColor.RGB = System.Drawing.Color.FromArgb(255, 0,
0).ToArgb();
//t1.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
//t1.Diagram.AutoLayout =
Microsoft.Office.Core.MsoTriState.msoTrue;
//t1.DiagramNode.AddNode(Microsoft.Office.Core.MsoRelativeNodePosition.msoAfterLastSibling, Microsoft.Office.Core.MsoDiagramNodeType.msoDiagramNode);
//PowerPoint.Shape t1 =
slide.Shapes.AddDiagram(Microsoft.Office.Core.MsoDiagramType.msoDiagramCycle,
100, 100, 100, 100);
//slide.Shapes.AddShape(24, 100, 100, 100, 100);
PowerPoint.Shape t1 = slide.Shapes.AddShape(24, 100, 100, 100,
100);
}
cheers
tat
Steve Rindsberg said:
As usual for these new features, PPT Help doesn't.
Try .AddShape(24, etc,etc,etc) instead.
24 is the constant for IGXGraphics/SmartArt
Hey All,
I'm trying to add some smart art to a powerpoint slide using c#. How would I
go about doing this?
Currently I'm trying to add it by:
PowerPoint.Shape t1 =
slide.Shapes.AddDiagram(Microsoft.Office.Core.MsoDiagramType.msoDiagramOrgChart, 100, 100, 100,
100);
While it is compiling alright, it does not do anything.
So,
1. Is this how I would go about adding smartart?
2. Am i adding smartart or something else?
3. How do i get it to show me some kind of organisation chart?
thnaks
tat
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:
www.pptfaq.com
PPTools:
www.pptools.com
================================================