Pictures in Excel

  Desert Andy 14:15 03 Mar 07

Having inserted a picture into an Excel worksheet, I am having trouble copying the picture to another worksheet or workbook since I am unsure what name the picture has, since there could be a number of different pictures on the original sheet. Any ideas how i could do this. Basically i am setting up a database which has picture ID on the page.

Thanks for your help.


  VoG II 14:18 03 Mar 07

If you click on the picture its name should be displayed in the address bar (where the cell address normally appears).

  Desert Andy 14:21 03 Mar 07

OK thats good thank you, didn't nb that. However, how can I pick up the picture name automatically using VB, is it possible

  VoG II 14:29 03 Mar 07

How would VBA know which picture was which?

You can list them:

Sub test()
Dim s As Shape
For Each s In ActiveSheet.Shapes
MsgBox s.Name
Next s
End Sub

  Desert Andy 14:38 03 Mar 07

Good question, I need to get a bigger brain!
I tried your routine which was great. I have set up a template worksheet, which I retrieve data for, then copy the data to another workbook for storage. I will only have 1 picture on the page, however, having run your routine i see that buttons i have generated are shown as well. Is there any way of getting the name of the only picture on a sheet. thanks for your time.

  VoG II 14:42 03 Mar 07

Assuming that you haven't renamed them from the default Picture1 etc then

Sub test()
Dim s As Shape
For Each s In ActiveSheet.Shapes
If s.Name Like "Pic*" Then MsgBox s.Name
Next s
End Sub

  Desert Andy 14:50 03 Mar 07

Fantastic thanks, hopefully this is the last question for a while, how do i rename the picture using VB?

  VoG II 15:00 03 Mar 07

Like this:

Sub Test2()
ActiveSheet.Shapes("Picture 1").Name = "MyPic"
End Sub

  Desert Andy 15:02 03 Mar 07

Sorry, i thought of one final question. If you put in some pictures and then delete them, the picture number keeps on going up. Is there any way of reseting the numbers down to the only pictures on the page.

  VoG II 15:20 03 Mar 07

Try this click here

  Desert Andy 15:33 03 Mar 07

All sorted, thanks for your help!

This thread is now locked and can not be replied to.

Sniper Elite 4 review: Headshotting Nazis has never felt so good

1995-2015: How technology has changed the world in 20 years

The Fresh New Fonts of 2017

WWDC 2017 dates: How to get WWDC 2017 tickets, when is WWDC 2017 and more details announced