PDA

View Full Version : global arrays are reset after pasting images from another sheet



mrjonesgl
08-22-2010, 07:53 AM
hi,
i have a few global arrays (declared in a module).
in Sheet1 i have a few images and i give the arrays some values. i copy one of the images and paste it in another Sheet and the arrays values reset.

can someone please advice?

thanks

Jan Karel Pieterse
08-22-2010, 11:37 AM
I know this happens when you do this with an ActiveX object (from the control toolbox). Are these Image objects from that toolbar? If so, try the same with the insert picture control on the drawing toolbar.

mrjonesgl
08-22-2010, 01:19 PM
can i create a form button and attach a picture and macro to it using VBA ?
can i do it to a picture control?

Jan Karel Pieterse
08-22-2010, 11:47 PM
A forms button cannot have a picture on its face. The other options are simple enough:

Sub PlaceButton()
With ActiveSheet.Buttons.Add(ActiveCell.Left, ActiveCell.Top, ActiveCell.Width, ActiveCell.Height)
.OnAction = "PlaceButton"
.Caption = "New button"
End With
End Sub

'Call this one like this:
'AddPicture "c:\MyDocuments\MyPic.jpg

Sub AddPicture(sFileName)
ActiveSheet.Pictures.Insert (sFileName)
End Sub