PDA

Click to See Complete Forum and Search --> : [RESOLVED] Align Controls on a VBA Form


VB4fun
Aug 18th, 2005, 02:02 PM
One of my first VBA forms, and I am stumped here....

In VB if select a number of controls, then select format, you can align the controls at one time. Is there a way to do this simply, in Excel VBA ?

RobDog888
Aug 18th, 2005, 02:14 PM
Nope, you need to code in each controls location.

VB4fun
Aug 18th, 2005, 02:20 PM
msgbox ("You have got to be kidding me"), vbExclamation


(thanks for the help anyway)

RobDog888
Aug 18th, 2005, 02:51 PM
Its a pain but it would like this...
Me.TextBox1.Move 100, 10, 1250, 345, False
Me.TextBox2.Move 100, Me.TextBox1.Top + Me.TextBox1.Height + 24, 1250, 345, False
Me.TextBox3.Move 100, Me.TextBox2.Top + Me.TextBox2.Height + 24, 1250, 345, False
'etc.

VB4fun
Aug 18th, 2005, 02:59 PM
needless to say, this could be time consuming with a fair amount of controls.
:(

Ecniv
Aug 19th, 2005, 04:17 AM
Yeah you can in designer...

Use ctrl to select more than one control.
Menu>Format>Align

:confused:

RobDog888
Aug 19th, 2005, 07:12 AM
Roght, but he wanted to do this via code. ;)

Ecniv
Aug 19th, 2005, 08:05 AM
In VB if select a number of controls, then select format, you can align the controls at one time. Is there a way to do this simply, in Excel VBA ?

Where does it mention vba coding?

VB4fun
Aug 19th, 2005, 08:12 AM
Ecniv is correct, I was not trying to do it via coding.

I was trying to do it within Excel, when creating a form under a new Dialog1 sheet.

However, I expanded my project and have gone into the VBA IDE, and am now creating my form, etc. there....Inside the IDE you have the Format/Align which helps tremendously... The controls take a little more to set up, but it seems to be working none the less.

(And it is teaching me VBA, which I have wanted to learn for some time.)

Thanks for the help along the way!

RobDog888
Aug 19th, 2005, 08:13 AM
Is there a way to do this simply, in Excel VBA ?And since he already is posting how its done in design mode, I put 1+1 together to make 2. :D

Ecniv
Aug 19th, 2005, 08:55 AM
No problem :) to both of you hehe

Can you set the thread to resolved please?