I would like to set the size and location of a userform and its controls
when the userform is initialized.
This seems straightforward, based on the documentation, but I can't get it
to work. Possibly because I also want to do this by putting all the code in
a routine outside the Userform_Initialize() routine.
For instance, I want to call the routine "TransformForm" while initializing
"UserForm1"
Library.TransformForm UserForm1
which begins
Library.TransformForm(vUserForm as UserForm )
passing UserForm1 by reference.
But, the instruction
vUserForm.Width= 400
causes an error ("does not support that property or method.") in that
routine.
But a similar instruction in the initialization routine
UserForm1.Width= 400
works just fine.
I have a similar problem using the.Move method--works in
Userform_Initialize(), fails in my outside routine.
I've simplified a lot away here in an effor to tbe clear. Can anyone tell me
what I am doing wrong? I'd be much obliged.
Thanks!
OughtFour - 14 Jun 2005 14:05 GMT
Sorry, that got garbled somehow. (Fixed below.)
> I would like to set the size and location of a userform and its controls
> when the userform is initialized.
[quoted text clipped - 11 lines]
>
> Lib rary.TransformForm
should be
TranformForm(vUserForm)
> passing UserForm1 by reference.
>
[quoted text clipped - 18 lines]
>
> Thanks!
Jonathan West - 14 Jun 2005 17:11 GMT
Try changing "vUserForm as UserForm" to "vUserForm as Object"
I suspect the problem may be that UserForm and UserForm1 are in fact two
different object types, and so you are getting problem when passing an
object of type UserForm1 when the routine is expecting something of type
UserForm.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>I would like to set the size and location of a userform and its controls
> when the userform is initialized.
[quoted text clipped - 37 lines]
>
> Thanks!
OughtFour - 14 Jun 2005 19:29 GMT
> Try changing "vUserForm as UserForm" to "vUserForm as Object"
Bingo! Thank you Mr. West, that solves the problem.