Thread: Userform Image
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Jennifer Jennifer is offline
external usenet poster
 
Posts: 385
Default Userform Image

I wish i new, I'm just trying an exapmle out of a book in order to try and
learn. NOT GOING SO WELL!
--
Though daily learning, I LOVE EXCEL!
Jennifer


"Art H" wrote:

Just an uninformed guess: Is it legal to form a string using an object
("Dim EmpFound As Range" and <"C:\Excel VBA 2003\" & EmpFound &
".jpg")?

Art

Jennifer wrote:
Yeah Bob,
I get the error when I type the first letter of the employees name. Have any
ideas? Thank you for your time.:)
--
Though daily learning, I LOVE EXCEL!
Jennifer


"Bob Phillips" wrote:

Hi Jennifer,

That is odd because it is surrounded by am On Error. Do you get that when
you try to run it, or after typing something in the textbox.

Img_Employee is the name of an image control on the userform, you have added
one?

"C:\Excel VBA 2003\" & EmpFound & ".jpg" is the name of the actual JPG file,
and it picks up the value from your employee list and appends that to the
path. If the files are GIF files, change the .jpg to .gif, but that cannot
be the error as the code works nicely for me even if the jpg doesn't exist
(doesn't display it of course).

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Jennifer" wrote in message
...
Hi Bob,
Thank you!
It is giving me the yellow highlight in this area

Img_Employee.Picture = LoadPicture( _
"C:\Excel VBA 2003\" & EmpFound & ".jpg")

To make sure I am understanding what is written & correct:
Img_Employee < This is the Image name on the form
C:\Excel VBA 2003 <This is the route to the file
.jpg < Picture will need to be in jpg format
--
Though daily learning, I LOVE EXCEL!
Jennifer


"Bob Phillips" wrote:

Jennifer,

One of the problems is using the Change event, as this fires on every
letter
typed into the textbox. For instance, if you have Bianca, Bill and Bob
in
the list, as soon as you type B it loads the first it finds. However, on
typing the second letter, it will do a more accurate match, Bi would
then
find Bill, and reload with the new image.

Although that might be a bit annoying, you should al end up okay, except
of
course if you try to enter Brian, where it will error on the Br, but an
image is already loaded.

What are you experiencing?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Jennifer" wrote in message
...
HELP! First time trying this, I am try an example out of a book. I'm
stuck.
Do I need to have anything in the Userform Initilize?

Trying to type Employee name and their picture show up in the
userform.
Thank you. Jennifer

Private Sub tb_EmpName_Change()
Dim EmpFound As Range
With Range("EmpList")
Set EmpFound = .Find(tb_EmpName.Value)
If EmpFound Is Nothing Then
MsgBox ("Employee Not Found!")
tb_EmpName.Value = ""
Me.tb_EmpName.SetFocus
Exit Sub
Else
With Range(EmpFound.Address)
tb_EmpPosition = .Offset(0, 1)
tb_EmpHireDate = .Offset(0, 2)
On Error Resume Next
Img_Employee.Picture = LoadPicture( _
"C:\Excel VBA 2003\" & EmpFound & ".jpg")
On Error GoTo 0
End With
End If
End With
End Sub
--
Though daily learning, I LOVE EXCEL!
Jennifer