Solved

Adding slide number to powerpoint with vb.net

Posted on 2014-02-21
2
1,142 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 50

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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

Have you ever been sent a PowerPoint presentation file and wondered why it filled your mailbox? Or have you ever sent a PowerPoint presentation by email and received complaints about the size? Or have you ever created a PowerPoint presentation and t…
Most folk recognise that Microsoft Excel, being a numbers-and-formulae-centric application attracts programmers due to the natural fit in mindset. Conversly, when opening Microsoft's dominant presentation creative application, few consider what…
The viewer will learn how to edit the master slide. They will also learn how to combine multiple themes into one master slide to use them in their presentation.
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.

856 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