1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| /// <summary>
///if you want to make a summary
/// </summary>
///
public static void MySummary()
{
// déclaration des variables
String strTable = "";
String strNumDiapo = "";
PowerPoint.Application app = Globals.ThisAddIn.Application;
PowerPoint.Presentation presDest = app.ActivePresentation;
PowerPoint.Selection selection = app.ActiveWindow.Selection;
//I need the number of slide to browse all my slides
int NumberOfSlide = presDest.Slides.Count;
//I go through my slides
for (int i = 1; i <= NumberOfSlide; i++)
{
// Important: Before you make your summary, you search other Slide contains Summary
//and you delete it
presDest.Application.ActiveWindow.View.GotoSlide(i);
presDest.Slides[i].Shapes.SelectAll();
//I go through my shape
foreach (PowerPoint.Shape shape in selection.ShapeRange)
{
try
{
if (shape.TextFrame.TextRange.Text == "Content")
{//I delete my Summary Slide
presDest.Slides[i].Delete();
NumberOfSlide = NumberOfSlide - 1;
break;
}
}
catch // If we fail, we just skip and try the next item
{
continue;
}
}
}
presDest.Slides.AddSlide(1, presDest.SlideMaster.CustomLayouts[1]);
//we go through our slides to retrieve information from titles
for (int i = 2; i <= NumberOfSlide+1; i++)
{
// We test if we are a title area
// We add that if it is a different title from the previous
if (presDest.Slides[i].Shapes.HasTitle == Microsoft.Office.Core.MsoTriState.msoTrue)
{
if (presDest.Slides[i].Shapes.Title.TextFrame.TextRange.Text != presDest.Slides[i - 1].Shapes.Title.TextFrame.TextRange.Text)
{
strTable += ("\r\n" + presDest.Slides[i].Shapes.Title.TextFrame.TextRange.Text);
strNumDiapo += "\r\n" + i.ToString();
}
}
}
presDest.Slides[1].Delete();
//I create a white page
// i use the Layout number seven
presDest.Slides.AddSlide(1, presDest.SlideMaster.CustomLayouts[7]);
// i take my white slide and i create shape
//I adjust the size of my differents shapes
Slide sld = presDest.Slides[1];
Shape titleShape = sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 300, 20, 400, presDest.PageSetup.SlideHeight / 2);
Shape shp = sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 50, 100, 600, presDest.PageSetup.SlideHeight / 2);
Shape numDiapo = sld.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 650, 100, 100, presDest.PageSetup.SlideHeight / 2);
//i insert my differents title and pages
shp.TextFrame.TextRange.Text = strTable;
shp.TextFrame.TextRange.Font.Size = 24;
numDiapo.TextFrame.TextRange.Text = strNumDiapo;
numDiapo.TextFrame.TextRange.Font.Size = 24;
titleShape.TextFrame.TextRange.Text = "Content";
titleShape.TextFrame.TextRange.Font.Size = 28;
titleShape.TextFrame.TextRange.Font.Color.RGB = Color.FromArgb(128, 128, 128).ToArgb();
presDest.Application.ActiveWindow.View.GotoSlide(1);
} |
Partager