PDA

View Full Version : View slide title in Powerpoint VBA editor



StevenF
05-11-2015, 04:38 AM
In the Powerpoint VBA editor, we get a list of slides in the VBA project window, categorised under "Microsoft PowerPoint Objects". This list will include slides that have ActiveX controls on them.
The slides appear with numbers on them ("Slide1", "Slide3", etc), and these numbers look like they are based on the order in which the slides were added to the presentation - not the actual order of the slides in the current presentation. However, the title or name of the slides is not included. This makes it confusing to work with, and difficult to find the slide that has the control one wants to work with.

13319

In Excel VBA, the layout of the editor is the same, with a list of worksheets. However, in Excel the name of the sheet is shown in brackets after the sheet number. So if Sheet1 is called "MyDataSheet", it will show up as "Sheet1 (MyDataSheet)".

13318

How can I achieve something similar in Powerpoint? Is there are way to control the name/title that is used to display each slide in the Powerpoint editor?

John Wilson
05-11-2015, 06:14 AM
First question is do you need to use ActivX objects at all. Many coders used to other program think they must use e.g. Command buttons to run code and ActivX textboxes to show text changes. This is not so and as you say the Slide Object names are confusing. (You cannot change the name)

If you must use ActivX don't use the slide object names at all. Use the Me keyword to refer to AxtivX shapes on the current slide e.g. msgbox Me.TextBox1. text

To refer to an ActivX object on for example Slide 3 (The real slide 3!)

MsgBox ActivePresentation.Slides(3).Shapes("TextBox1").OLEFormat.Object.Text

Paul_Hossler
05-12-2015, 11:59 AM
You can assign a .Name to a slide that survives re-arranging, but there is no Excel-like Code Name for a slide w/o a code containing control on it



Option Explicit
Sub test()
ActivePresentation.Slides(1).Name = "Intro"
ActivePresentation.Slides(2).Name = "Middle"
ActivePresentation.Slides(3).Name = "Ending"

MsgBox ActivePresentation.Slides("Middle").Shapes(1).TextFrame.TextRange.Text

End Sub



I had a simple 3 slide test, ran the above macro, and then commented out the 3 .Name lines, re-arranged the slides, I I still found the "Middle" slide