Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-12-2013, 09:35 PM
excelledsoftware excelledsoftware is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2003
IT Specialist
All Shapes on slide
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default All Shapes on slide

I have been learning a lot about VBA lately but am stumped on this one. I would like a loop that goes through the current slide of my presentation and grabs all the shape names. I know how to get all the names in a variable but cant get the loop started to extract each shapes name.



Any help is appreciated.
Reply With Quote
  #2  
Old 08-12-2013, 11:09 PM
JohnWilson JohnWilson is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Where do you want the shape names to end up?

Message Box?
Array?
Immediate pane?
Print on slide?
In a text file?
Somewhere else?

Example

Sub getShapeNames()
Dim oshp As Shape
Dim osld As Slide
Dim strReport As String
strReport = "Shapes On Slide" & vbCrLf & "===========" & vbCrLf & vbCrLf
On Error Resume Next
Set osld = ActiveWindow.View.Slide
If Not osld Is Nothing Then ' check slide in view
For Each oshp In osld.Shapes
strReport = strReport & oshp.Name & vbCrLf
Next oshp
If strReport = "" Then strReport = "No shapes!"
MsgBox strReport
End If
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 08-13-2013, 04:41 PM
excelledsoftware excelledsoftware is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2003
IT Specialist
All Shapes on slide
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Sweet Thanks John,

Sorry for not being really specific this time but I am working on learning VBA so I just needed the start on this code. I'm going to play around with it and see what I can do.

Thank you again.
Reply With Quote
  #4  
Old 08-14-2013, 02:36 AM
JohnWilson JohnWilson is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

That's a good way to learn.

Since it's not at all obvious here's how to put the report in a file on the Desktop

Sub getShapeNames_toFile()
Dim oshp As Shape
Dim osld As Slide
Dim strReport As String
Dim filenum As Integer
Dim strSavePath As String
filenum = FreeFile ' next available # usually but not always 1
strSavePath = Environ("USERPROFILE") & "\Desktop\report.txt"
strReport = "Shapes On Slide" & vbCrLf & "===========" & vbCrLf & vbCrLf
On Error Resume Next
Set osld = ActiveWindow.View.Slide
If Not osld Is Nothing Then ' check slide in view
For Each oshp In osld.Shapes
strReport = strReport & oshp.Name & vbCrLf
Next oshp
If strReport = "" Then strReport = "No shapes!"
Open strSavePath For Output As filenum
Print #filenum, strReport
Close filenum
End If
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 09-07-2013, 10:05 AM
excelledsoftware excelledsoftware is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2003
IT Specialist
All Shapes on slide
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Sorry to ask again but is there a way to the msgbox code above without having the presentation open I am trying the following.

Sub getShapeNames()
Dim oshp As Shape
Dim Mylibrary As Presentation
Dim osld As Slide
Dim strReport As String
strReport = "Shapes On Slide" & vbCrLf & "===========" & vbCrLf & vbCrLf
On Error Resume Next
Set Mylibrary = Presentations.Open(Environ("USERPROFILE") & "\My Documents\CustomShapes.ppt", WithWindow:=False)
For Each oshp In Mylibrary.Shapes
strReport = strReport & oshp.Name & vbCrLf
Next oshp
msgbox strReport
Reply With Quote
  #6  
Old 09-07-2013, 10:51 PM
JohnWilson JohnWilson is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

The only way to do this without opening would be to query the XML. This is not a simple thing to do! You would need to Google Microsoft XML DOM or OpenXML SDK.

Be warned though this is an order of magnitude harder than what you are doing.

Is there a problem opening a windowless copy (and closing it when you are done) It should be quite transparent.
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #7  
Old 09-08-2013, 10:05 AM
excelledsoftware excelledsoftware is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2003
IT Specialist
All Shapes on slide
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Quote:
Originally Posted by JohnWilson View Post
The only way to do this without opening would be to query the XML. This is not a simple thing to do! You would need to Google Microsoft XML DOM or OpenXML SDK.

Be warned though this is an order of magnitude harder than what you are doing.

Is there a problem opening a windowless copy (and closing it when you are done) It should be quite transparent.
Oh wow. Yeah I dont want anything that difficult right now. Opening a windowless copy should be fine, actually I thought that was what I was trying to do.
Reply With Quote
  #8  
Old 09-14-2013, 11:14 AM
excelledsoftware excelledsoftware is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2003
IT Specialist
All Shapes on slide
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Quote:
Originally Posted by excelledsoftware View Post
Oh wow. Yeah I dont want anything that difficult right now. Opening a windowless copy should be fine, actually I thought that was what I was trying to do.
I tired my above code again and I still cant get it to work as a windowless copy. Is there different code I should use?
Reply With Quote
  #9  
Old 09-14-2013, 07:24 PM
excelledsoftware excelledsoftware is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2003
IT Specialist
All Shapes on slide
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Quote:
Originally Posted by excelledsoftware View Post
I tired my above code again and I still cant get it to work as a windowless copy. Is there different code I should use?
I got it.
Just had to do a little bit of research here is the solution.

Code:
Sub shapelist()
Dim curlibrary As Presentation
Dim oshp As Shape
Dim AllShapeMsg As String
Dim curosld As Slide
Set curlibrary = Presentations.Open(Environ("USERPROFILE") & "\My Documents\CustomShapes.ppt", WithWindow:=False)
Set curosld = curlibrary.Slides(1)
For Each oshp In curosld.Shapes
AllShapeMsg = AllShapeMsg & oshp.Name & vbCrLf
Next oshp
curlibrary.Close
MsgBox AllShapeMsg


End Sub
Thanks everybody
Reply With Quote
  #10  
Old 09-15-2013, 04:03 AM
JohnWilson JohnWilson is offline All Shapes on slide Windows 7 64bit All Shapes on slide Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Well done!
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
All Shapes on slide Copy & Paste Shapes & Motion Paths from 1 Slide Size to Another buckaroobanzai PowerPoint 1 06-08-2012 05:32 AM
All Shapes on slide Where did map shapes go? SueK PowerPoint 1 01-20-2011 04:30 AM
All Shapes on slide Find and add new Shapes bonani PowerPoint 1 11-26-2009 06:21 PM
Shapes Will Not Display JoeTx Visio 0 03-13-2008 09:01 AM
My Shapes some appear some don't Jean-Paul Visio 0 03-01-2006 01:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft