Pictures in Excel

  Desert Andy 14:15 03 Mar 2007
Locked

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.

Andy

  VoG II 14:18 03 Mar 2007

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 2007

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 2007

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 2007

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 2007

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 2007

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

  VoG II 15:00 03 Mar 2007

Like this:

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

  Desert Andy 15:02 03 Mar 2007

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 2007

Try this click here

  Desert Andy 15:33 03 Mar 2007

All sorted, thanks for your help!

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

Elsewhere on IDG sites

Best phone camera 2017

Stunning new film posters by Hattie Stewart, Joe Cruz & more

iPad Pro 10.5in (2017) review

28 astuces pour profiter au mieux de votre iPhone