Solved

Adding slide number to powerpoint with vb.net

Posted on 2014-02-21
2
1,130 Views
Last Modified: 2014-02-24
I'm automating the creation of powerpoint presentation using VB.net and powerpoint 2010.  How can i make slide numbers visible programmatically?
0
Comment
Question by:HyperBPP
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 300 total points
ID: 39879031
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
 
LVL 23

Assisted Solution

by:JSRWilson
JSRWilson earned 200 total points
ID: 39879578
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

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to simulate drawing numbers or names from a hat or bag using vba in PowerPoint and prevents duplicate items being selected. It’s not difficult to choose a (semi) random number in vba. The RND function returns a decimal numb…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now