View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
danpt danpt is offline
external usenet poster
 
Posts: 49
Default Picture # assignment

No, still no good


"Gord Dibben" wrote:

You are correct.

Doesn't like the space in "Picture "

Not sure why but will ponder on that a while.

Try this revision...................rename by double-naming then rename
again.

Public Sub ReNamePics()
Dim Pic As Shape, K As Long
For Each Pic In Selection.ShapeRange
Pic.Name = Pic.Name & Pic.Name
Next Pic
For Each Pic In Selection.ShapeRange
K = K + 1
Pic.Name = "Picture " & K
Next Pic
End Sub


Gord

On Fri, 3 Apr 2009 14:51:01 -0700, danpt
wrote:

Many thanks, Gord
I found out that I couldn't use
Pic.Name = "Picture " & K
Is it correct?

"Gord Dibben" wrote:

On a sheet select all pictures then run this macro.

Public Sub ReNamePics()
Dim Pic As Shape, K As Long
For Each Pic In Selection.ShapeRange
K = K + 1
Pic.Name = "MyPic" & K
Next Pic
End Sub

Or run this is you have a list of names to use.

Sub Rename_Pics22()
'select all pictures then rename with a list starting at A2
Dim Pic As Shape
Dim rng As Range
Dim i As Integer
On Error GoTo endit
Set rng = Range("A2")
For Each Pic In Selection.ShapeRange
Pic.Name = rng.Offset(i, 0).Value
i = i + 1
Next Pic
Exit Sub
endit:
MsgBox "there is a picture by that name, re-type a name"
End Sub


Gord Dibben MS Excel MVP

On Thu, 2 Apr 2009 21:52:04 -0700, danpt
wrote:


My book has many pictures.
Picture #s kept going higher and higher every time I made a change to the
book and the #s were skipping.
Is there a way to get a list of the Picture #s in the book.
I want to rename all the Pictures to a low # start and more consecutive.
Thanks