View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Macro to enlarge a picture

Even though you're happy with Chuck's solution, you could use buttons from the
Forms toolbar and have your code determine which picture to modify.

Option Explicit
Sub testme()

Dim myButton As Button
Dim myPict As Picture
Set myButton = ActiveSheet.Buttons(Application.Caller)
Set myPict = FindPicture(myButton, ActiveSheet)
If myPict Is Nothing Then
MsgBox "No picture on that button's row"
Else
'code to adjust picture
MsgBox myPict.Name
End If

End Sub


Function FindPicture(myBTN As Button, wks As Worksheet) As Picture

Dim myPict As Picture
Dim PictToAdj As Picture

With wks
Set PictToAdj = Nothing
For Each myPict In .Pictures
If Intersect(.Range(myPict.TopLeftCell, myPict.BottomRightCell), _
myBTN.TopLeftCell.EntireRow) Is Nothing Then
'keep looking
Else
Set PictToAdj = myPict
Exit For 'stop looking
End If
Next myPict
End With

Set FindPicture = PictToAdj

End Function


WightRob wrote:

I have found a partial solution. I have recorded 2 macros, one to
enlarge the picture and one to reduce it. I have assigned these macros
to buttons adjacent to the picture. The problem with this is that the
macro applies to a specific picture. To make this work, I would have
to record 2 macros for every picture. (I have a lot of records!). Does
anyone know how to make the macro apply to the picture next to the
button selected?

--
WightRob
------------------------------------------------------------------------
WightRob's Profile: http://www.excelforum.com/member.php...o&userid=13799
View this thread: http://www.excelforum.com/showthread...hreadid=548638


--

Dave Peterson