simple code, for each

J

John

I want to rename all 10 or so pictures in my worksheet...

Public Sub ReNamePics()
Dim Pic As Shape, K As Long
For Each Pic In ActiveSheet '<<<<<<<<< error here
K = K + 1
Pic.Name = "pic" & K
Next Pic
MsgBox "done"
End Sub
 
J

Jim Cone

Untested...
'--
Public Sub ReNamePics()
Dim Pic As Shape, K As Long
For Each Pic In ActiveSheet.Shapes
If Pic.Type = msoPicture Then
K = K + 1
Pic.Name = "pic" & K
End If
Next Pic
MsgBox "done"
End Sub
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"John"
<[email protected]>
wrote in message
I want to rename all 10 or so pictures in my worksheet...

Public Sub ReNamePics()
Dim Pic As Shape, K As Long
For Each Pic In ActiveSheet '<<<<<<<<< error here
K = K + 1
Pic.Name = "pic" & K
Next Pic
MsgBox "done"
End Sub
 
G

Gord Dibben

Public Sub ReNamePics()
Dim Pic As Shape, K As Long
ActiveSheet.DrawingObjects.Select
For Each Pic In Selection.ShapeRange
K = K + 1
Pic.Name = "pic" & K
Next Pic
MsgBox "done"
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top