Monday, 18 June 2012

Lesson 33: Excel Image Controls

Image Control
There is a control in the toolbox called "Image" . Within this control you can show all types of pictures. You set an image control on  a userform and you submit a picture in the property "Picture" . The picture becomes part of the control and userform.

Fitting the Picture
The first thing that you want to do is to fit the picture in the image control to make the size of the control adapt to the size of the picture.
When you are in the Visual Basic Editor and you single click on an image control a frame appears around it with 8 stretchers (picture below). If you double click on the middle stretcher  (when a two tips arrow shows) of the right side or on the middle one at the  bottom or on the bottom right corner stretcher  the image control will adapt to the size of the image. Double clicking anywhere else will take you to the VBA code and will not adapt the control size to the picture size.

PictureSizeMode Property
Another property of the image control is the PictureSizeMode.
If the property is set to the default value 0-frmPictureSizeModeClip the control size can be changed without the picture size being modified. So you can see only part of the picture or there can be a background behind it in a clolor color you can change at will.
If the property is set to the 1-frmPictureSizeModeStretch the picture is resized as the control is. The image fills the control.
If the property is set to the 3-frmPictureSizeModeZoom the picture is resized as the control is but the picture and background are present.

No comments:

Post a Comment