View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Indexing of Shapes

You can control the pictures when you insert them:

Option Explicit
Sub testme()

Dim myPict As Picture
Dim myRng As Range

With ActiveSheet
Set myRng = .Range("b3:c4")
Set myPict = .Pictures.Insert("c:\my documents\my pictures\badday.jpg")

End With
With myPict
.Top = myRng.Top
.Left = myRng.Left
.Width = myRng.Width
.Height = myRng.Height
.Name = "Pict_" & .TopLeftCell.Address(0, 0)
.OnAction = "'" & ThisWorkbook.Name & "'!testme03"
End With

End Sub
Sub testme03()
dim myPict as picture
MsgBox "you clicked: " & Application.Caller
set mypict = activesheet.pictures(application.caller)
msgbox mypict.name
End Sub

avveerkar wrote:

I need to import GIF images as buttons in my workbook. I then want to
control their behaviour in my procedures. To identify these button
objects I recorded a micro and saw that they are identified as some
Picture No eg. Shapes("Picture15"), shapes("Picture 23"). I have no
clue how this picture numbering ( indexing of shapes ) is handled by
VBA. One button is Picture17 and other is Picture23. On the face of
this it looks very random but I am sure there is some method. Like
when we use commandbuttons each button has a name and we can address
that by the name. How do I identify GIF used as buttons? I must know
the name or some identifier if I want to control the behaviour of the
GIF buttons. Pl help.

--
avveerkar
------------------------------------------------------------------------
avveerkar's Profile: http://www.excelforum.com/member.php...o&userid=30338
View this thread: http://www.excelforum.com/showthread...hreadid=503254


--

Dave Peterson