Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Changing UserForm Appearance with VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
OughtFour - 13 Jun 2005 22:07 GMT
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.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.