Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2012, 10:11 PM
CatMan CatMan is offline How do you identify the ID of a picture in PowerPoint? Windows 7 32bit How do you identify the ID of a picture in PowerPoint? Office 2010 32bit
Intermediate
How do you identify the ID of a picture in PowerPoint?
 
Join Date: Apr 2012
Posts: 39
CatMan is on a distinguished road
Default How do you identify the ID of a picture in PowerPoint?

Hi Forum, I have a slide with 3 pictures on it, I presume each picture has a separate ID (Picture 1, 2 3???) but how do I see the ID? I am writing an Excel based automation that deletes pictures on variou slides based on users input, the user must specify which of the 3 pictures to delete. I don't want to say "the middle one!, (hahaha). In Excel, when you click on a chart or autoshape, the ID appears in the label field (beside f of x).

I just spent an hour on the internet, with no luck. Thanks for your help on this.

Incidentally, if, by chance, the PowerPont GUI cannot display the picture ID (I hope this is not the case), can someone suggest some VBA code that would report the user selected picture by msgbox. I could set this code to a hot key and msgbox the ID to the user. But seriously, it's hard to believe the GUI does not do this.

Last edited by CatMan; 04-09-2012 at 03:14 PM.
Reply With Quote
  #2  
Old 04-13-2012, 07:07 AM
JohnWilson JohnWilson is offline How do you identify the ID of a picture in PowerPoint? Windows 7 64bit How do you identify the ID of a picture in PowerPoint? 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

AFAIK Excel doesn't show the shape ID in the GUI. It does show the Shape name (not the same thing the ID cannot be changed the name can)

If this is what you need you need to show the selection pane. HOME Tab.. select drop menu (far right in Editing) This will show the name and allow you to rename the picture.

If you really want the ID you can only get it with code
msgbox ActiveWindow.Selection.ShapeRange(1).Id

If you use names you need to be sure noone is going to change them!

PowerPoint has a cool feature "Shape tags" You can add a tag to any shape to identify it. This is ONLY possible in code and the average user cannot change them:

Some info
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 04-13-2012, 04:41 PM
CatMan CatMan is offline How do you identify the ID of a picture in PowerPoint? Windows 7 32bit How do you identify the ID of a picture in PowerPoint? Office 2010 32bit
Intermediate
How do you identify the ID of a picture in PowerPoint?
 
Join Date: Apr 2012
Posts: 39
CatMan is on a distinguished road
Default

Hi John, Thanks for the info, it really helps! I discovered I can get the picture ID by applying an animation, the animation pane reports the picture ID but this is a round about way to do it. Selection Pane gets me a little closer to solving my problem. When I apply selection pane to an arbitrary PowerPoint example one slide has two pictures with the same name 'Picture 30' (twice). That surprised me. When I use your code suggestion '....ShapeRange(1).Id' each Picture 30 has a different ID, which is more logical to me.

Can you offer some code that would allow me to delete a picture by Picture name or by Picture ID. Also I would like to adjust the location of a picture on the slide (move it). Here's what I have tried so far (but it doesnt work)

Code:
'Delete picture (by Picutre number or ID number)
ActiveWindow.Name("Picture 30").Delete
ActiveWindow.ShapeRange(1).ID("13340").Delete.

'Move picture (by points)
ActiveWindow.ShapeRange(1).ID("13340').left(30)
ActiveWindow.ShapeRange(1).ID("13340').top(30)
Reply With Quote
  #4  
Old 04-14-2012, 12:12 AM
JohnWilson JohnWilson is offline How do you identify the ID of a picture in PowerPoint? Windows 7 64bit How do you identify the ID of a picture in PowerPoint? 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

PowerPoint vba doesn't really offer a convenient way to use ID like that.

The best solution is to write a custom function

Code:
Function ShapeByID(ThisSlide As Slide, ThisID As Long) As Shape
For Each ShapeByID In ThisSlide.Shapes
If ShapeByID.Id = ThisID Then
Exit Function
End If
Next
End Function
And an example of how to use to delete shape with ID=8 from slide 1

Code:
Sub exampleID()
On Error Resume Next
ShapeByID(ThisSlide:=ActivePresentation.Slides(1), ThisID:=8).Delete
End Sub
An easier solution is to use the selection pane to rename using unique names then ....

Code:
Sub DeleteByName()
On Error Resume Next ' in case shape doesn't exist
ActivePresentation.Slides(1).Shapes("MyName").Delete
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials

Last edited by JohnWilson; 04-14-2012 at 06:38 AM.
Reply With Quote
  #5  
Old 04-17-2012, 03:29 PM
CatMan CatMan is offline How do you identify the ID of a picture in PowerPoint? Windows 7 32bit How do you identify the ID of a picture in PowerPoint? Office 2010 32bit
Intermediate
How do you identify the ID of a picture in PowerPoint?
 
Join Date: Apr 2012
Posts: 39
CatMan is on a distinguished road
Default

John, my appoligies for a slow reply, had out of town visitors over till this morning. Your lastest reply was very helpful. Deleting a slide by name moves me ahead nicely.

I still need to move a picture by name, something like
Code:
ActiveWindow.ShapeRange(1).("MyName").left(30)
and rename a picture by name, something like
Code:
ActiveWindow.ShapeRange(1).("MyName").rename("NewName")
but I think I should mark this thread as solved and post this question under a new thread (which I will post right after this).

John, thank you for your help, this was a hard nut for me to crack, I really appreciate your input. This forum is a powerful resource. And thanks to all who visited.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Powerpoint automatically changing picture size when adding a picture (2010) One_Life PowerPoint 7 01-20-2012 06:57 AM
How do you identify the ID of a picture in PowerPoint? Picture size for Powerpoint roligan PowerPoint 2 12-22-2011 07:18 AM
How do you identify the ID of a picture in PowerPoint? Changing opacity of a picture on powerpoint Straitsfan PowerPoint 1 05-18-2011 10:30 AM
How do you identify the ID of a picture in PowerPoint? How to identify the paragraph number you are on SaneMan Word VBA 1 05-18-2011 05:43 AM
PowerPoint 2003 - Change default location for Insert Picture Fee PowerPoint 0 05-12-2011 02:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:52 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