Solved

Adding slide number to powerpoint with vb.net

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

758 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

18 Experts available now in Live!

Get 1:1 Help Now