moving an image in a userform

G

Guest

hi all!

i have a userform (userform1) and an image on the userform (image1)

i am trying to set the top, left, height and width using the following:

Public Sub setLogo(logo As Image, form As UserForm)

form.logo.Left = 6
form.logo.Top = 6
form.logo.Width = 66
form.logo.Height = 48

End Sub

but i am getting
Run-time error '438'
Object doesn't support this property or method

what am i doing wrong?

oh - and the call is

call setLogo(Image1,UserForm1)

tia

J
 
H

Harald Staff

Hi J

If you click "debug" instead of "end" then you might be shown the error. Or
maybe not, if the macros are nested too deep then no luck, it says
"userform1.show" instead.

I can't test it properly without more detail. But two things from reading
it: Width and height may not make sense if you autosize the image. And
"Image1" may or may not make sense, depending on where this code is. Try
call setLogo(UserForm1.Image1,UserForm1)
call setLogo(Me.Image1,UserForm1)

(But why do you need a macro for that operation at all, it seems pretty
fixed ?)

HTH. Best wishes Harald
 
P

Peter T

In setLogo, remove the second argument "form as Userform" and "form." in
four places preceding logo.

Then simply -
setLogo UserForm1.Image1

or maybe
Dim img As MSForms.Image
Set img = UserForm1.Image1
setLogo img

or
Call setLogo(img)

Regards,
Peter T
 
P

Peter T

Alternatively -

Public Sub setLogo2(form As UserForm, sName As String)

form(sName).Left = 6
form(sName).Top = 6
form(sName).Width = 66
form(sName).Height = 48

End Sub

Regards,
Peter T


"Peter T" wrote in message :
 
G

Guest

hi Harald - thanks for the response!

- i did hit debug - and the error was
on the line
the image is not autosized

the call to setLogo() is in the userform UserForm1 (in UserForm_Initialize)

the code itself is in a module (same project)

and as far as why i need it, i don't really but - it's a pain in the a$$ to
have to set the loc and width of this 40 or 50 times as i'm creating the
userform pages. find it much easier just to plunk it close to where i want
it, create the rest of the stuff and then have it force it into position.
could be wrong - but that's just me =)

in all honesty - all i have is a userform, with an image - and
UserForm_Initialize()
with that call inside.
 
G

Guest

hmmm

i got it to work by changing

call setLogo(me.image1)

and obviously adjusting the sub to accept only 1 arg
and each line i removed the form. .

thanks guys

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top