Cell data to a userform object

S

Syrous

Hey everyone!

I'm trying to take the information from a cell which contains a file location and then using that location change the property of an object in one of my userforms. The code I'm showing is the idea of what I want to do but it's not right.

UserForm4.Label4.Picture = LoadPicture (Sheets("Sheet1").Cells(counter, 2).value)

If someone has a solution that'd be great. Thanks.
 
T

Tom Ogilvy

LoadPicture only works with picture files.

--
Regards,
Tom Ogilvy


Syrous said:
Hey everyone!

I'm trying to take the information from a cell which contains a file
location and then using that location change the property of an object in
one of my userforms. The code I'm showing is the idea of what I want to do
but it's not right.
 
T

Tom Ogilvy

That said, if Sheets("Sheet1").Cells(counter,2).Value contained the string
C:\WINNT\Coffee Bean.bmp

as an example, it worked fine for me as written

Private Sub UserForm_Initialize()
counter = 2
UserForm1.Image1.Picture = LoadPicture("C:\Winnt\Coffee Bean.bmp")
UserForm1.Label1.Picture = LoadPicture(Sheets(1).Cells(counter, 2).Value)
End Sub


Note that the image looked better in the image control.
 
B

Bob Phillips

Hate to say it, but it works fine for me. What do you have in the variable
counter? What error do you get?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Syrous said:
Hey everyone!

I'm trying to take the information from a cell which contains a file
location and then using that location change the property of an object in
one of my userforms. The code I'm showing is the idea of what I want to do
but it's not right.
 
Top