|
|
Pasting a Bitmap to a UserForm controlThis one is odd because it's undocumented and somewhat counter-intuitive. But, on the other hand, it's also a very useful tip. VBA programmers are familiar with Excel's UserForms. The UserForm object, as well as many of the ActiveX controls that are placed on a UserForm, can display an image -- the object's Picture property.
How to set the Picture propertyIf you believe Excel's online help, you'll think that there are two ways to set the Picture property for an object:
But wait! There's another way. And it doesn't even require that the image is stored in a file. Here's the trick:
MoreImportantly, the picture that you paste to a control need not be stored in a file. Any picture that can be copied to the Clipboard can be pasted to an object's Picture property. And this includes charts stored in a worksheet. The trick here is to copy the chart as a picture: Click the chart, press Shift, and choose Copy Picture from Excel's Edit menu. Once copied, you can paste the picture of the chart to your UserForm control. When pasting a chart, it's important to understand that the picture is not linked to the original chart. So if the chart changes, the picture will not change. For ways to display a "live" chart on a UserForm, see:
|