MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Add Picture to a user form


Posted by Richie Turner on July 17, 2001 3:07 AM

I have a user form with an Image control that currently does not contain an image. When the application is running, I'd like the user to be able to click a button which would then allow him to select an image from a dialog box and display it in the image control.

anybody help, it't the selecting and loading image part that I don't know where to start

many thanks

Richie


Posted by Ivan F Moala on July 17, 2001 3:32 AM

This should get you started....just look up
the online help for more info.

Assumes Userform1, Commandbutton, ListBox
Change Directory as required.


Const PictDir As String = "C:\images\gif\1\"

Private Sub CommandButton1_Click()
Image1.Picture = LoadPicture(PictDir & ListBox1.Text)
End Sub

Private Sub UserForm_Initialize()
Dim F

F = Dir(PictDir & "*.gif")

Do While Len(F) > 0
ListBox1.AddItem F
F = Dir()
Loop

End Sub

HTH

Ivan