Adding slide number to powerpoint with vb.net

I'm automating the creation of powerpoint presentation using VB.net and powerpoint 2010.  How can i make slide numbers visible programmatically?
LVL 6
HyperBPPAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Rgonzo1971Connect With a Mentor Commented:
Hi,

With VBA it should be
Sub Macro()
For Each sld In ActivePresentation.Slides
    With sld.HeadersFooters
        .SlideNumber.Visible = msoTrue
    End With
Next
End Sub

Open in new window

Regards
0
 
JSRWilsonConnect With a Mentor Commented:
Rgonzo's code will add numbers to all existing slides.

However if you mean set the default for NEW slides to numbered that is a different matter.

Don't think it's possible in vba except by using executeMso and sendkeys which may not be reliable

Sub numl()
Dim osld As Slide
Dim ocust As CustomLayout
ActiveWindow.Selection.Unselect ' ensure no text selected
Set ocust = ActivePresentation.SlideMaster.CustomLayouts(2)
Set osld = ActivePresentation.Slides.AddSlide(1, ocust)
If Not osld.HeadersFooters.SlideNumber.Visible Then ' check if already set to show all
PowerPoint.Application.CommandBars.ExecuteMso ("HeaderFooterInsert")
SendKeys ("%N")
SendKeys ("%Y")
SendKeys ("ESC")
End If
osld.Delete
End Sub
0
All Courses

From novice to tech pro — start learning today.