Name

form.Picture [= setting]

Synopsis

Sets or returns the picture loaded as the background. The picture can be set at design time in the Properties window or at runtime using the LoadPicture function. For example, the following code displays a logo as the background of a form, centers the picture, and sizes it to fit the form while preserving the aspect ratio:

    Private Sub UserForm_Initialize(  )
        Me.Picture = LoadPicture(ThisWorkbook.Path & "\logo.bmp")
        Me.PictureAlignment = fmPictureAlignmentCenter
        Me.PictureSizeMode = fmPictureSizeModeZoom
    End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.