Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
One of my customers asked me a question about PowerPoint 2007. He wanted to have the slide number and the total number of the slides in his presentations (ie: 3/45). I quickly developped a VSTO 3.0 Addin and here is the code. I created a Ribbon Button to call this method. I simply put this method in the ThisAddin.cs file:
/// <summary>
/// Format the slide numbers with: number/total number
/// </summary>
public void FormatSlideNumbers()
{
int iSlides = 0;
string SlideCounterName = "Slide Number Placeholder";
try
{
// For every Slide in the Active Presentation
for ( iSlides = 1; iSlides <= this.Application.ActivePresentation.Slides.Count; iSlides++)
{
// For every Shape in the Slide
foreach (PowerPoint.Shape myShape in Application.ActivePresentation.Slides[iSlides].Shapes)
{
// Check the shape containing "Slide Number Placeholder"
if (myShape.Name.Contains(SlideCounterName))
{
string CurrentslideNumber = iSlides.ToString();
// Change the Slide's placeholder's name
myShape.TextFrame.TextRange.Text = CurrentslideNumber + @"/" + this.Application.ActivePresentation.Slides.Count.ToString();
myShape.Width = PowerPointAddInTools.Properties.Settings.Default.SlideWidth;
}
}
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("An error has occured: " + ex.Message, "PowerPoint Tools", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
Enjoy !
Comments
Anonymous
June 18, 2009
PingBack from http://fancyporchswing.info/story.php?id=2936Anonymous
July 05, 2013
Try TNOS-Total Number Of Slides. You can automatically insert total number of visible pages and set an arbitrary persistent pattern for numbering including the total number (freeware www.symod.com/TNOS )