Archive of Mr Excel Message Board

Back to Controls in Excel archive index
Back to archive home

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

Re: Add Picture to a user form
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

This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our
online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.