DatabaseLessons.com

'Serving the Microsoft® Access
Community since 1997'

News/Blog
Tables
Queries
Forms
Reports
Modules
Miscellaneous
Subscribe
Free Samples
Videos
Services
Links
About Us

 

 

How to Name Powerpoint Objects

Powerpoint 2000 does not have a built in tool for naming objects the way Access does. As my regular readers will know, I ALWAYS name my objects, rather than stick with the default names Microsoft products give them.

(article continues after sponsor spot)



Here is one way to name the objects.

  • open the Powerpoint file that you need automated
  • from the Menu Toolbar choose Tools | Macros | Visual Basic Editor
  • copy the following code into the resulting VBA editor screen
  • save
  • from the Menu Toolbar choose File | Close and Return to Microsoft Powerpoint
  • select the object that you wish to rename
  • from the Menu Toolbar choose Tools | Macros | Macro
  • select the macro NameIt
  • click once on the Run button
  • type the new name for the object
  • click once on the OK button (or press the Enter key)
Sub NameIt()

  Dim sResponse As String

  With ActiveWindow.Selection.ShapeRange(1)
    sResponse = InputBox("new name ...", "Rename Shape", .Name)
    Select Case sResponse
     ' blank names not allowed
     Case Is = ""
       Exit Sub
     ' no change?
     Case Is = .Name
       Exit Sub
     Case Else
       On Error Resume Next
       .Name = sResponse
       If Err.Number <> 0 Then
         MsgBox "Unable to rename this shape"
       End If
    End Select
  End With

End Sub

If you have a Powerpoint slide with a large number of objects, you may accidentally forget one. I also have developed code that lists all the objects.

Here is how to get the list of all objects.

  • open the Powerpoint file that you need automated
  • from the Menu Toolbar choose Tools | Macros | Visual Basic Editor
  • copy the following code into the resulting VBA editor screen
  • save
  • from the Menu Toolbar choose File | Close and Return to Microsoft Powerpoint
  • from the Menu Toolbar choose Tools | Macros | Macro
  • select the macro All_Names
  • click once on the Run button
  • open the VBA editor again
  • from the VBA editor Menu choose View | Immediate Window
  • the list should appear in the resulting window at the bottom of the VBA editor
  • select the entire list and copy and paste it to notepad, etc, and save or print it
Sub All_Names()

  Dim oShp As Shape
  For Each oShp In ActivePresentation.Slides(1).Shapes
     Debug.Print oShp.Name
  Next oShp

End Sub

Your Powerpoint file is now ready to be automated by Access.

Happy Coding

 
Note: This web site dedicated to MS Access database users is an independent publication of Richard W. Killey and is not affiliated with, nor has it been authorized, sponsored, or otherwise approved by Microsoft® Corporation.
 

 

© 2006, 2007, 2008 Richard W. Killey. All Rights Reserved. - Privacy Policy