Indexing of Shapes

  • Thread starter Thread starter avveerkar
  • Start date Start date
A

avveerkar

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.
 
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
 
Dear Dave Peterson,

Thank you for response. It answers my question very well.


A V Veerkar
 

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

Back
Top