Microsoft Office Tutorials and References
In Depth Information
Display a Real-Time Chart in a UserForm
displAy A rEAl-TiME cHArT in A usErforM
Earlier in this lesson you saw how to load a picture into an Image control. You can also create a
temporary graphic file on the fly, load that file into a UserForm’s Image control, and delete the
temporary graphic file, all with the user being none the wiser.
Figure 20-7 shows a list of cities, ranked by their approximate population. Elsewhere in the
workbook is a Chart sheet named Chart1 with a bar chart of this city population data. You can
represent the Chart1 sheet’s chart in real time by exporting its image as a .gif file and loading it onto an
Image control when the UserForm is called. Figure 20-7 shows the result and following that is the
Initialize event code that handles this task.
Private Sub UserForm_Initialize()
Image1.Picture = LoadPicture(“CityPopulation.gif”)
Image1.PictureSizeMode = fmPictureSizeModeZoom
You can print a UserForm, even if it is not open, with the following line: