Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Excel VBA Form Move


Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2009, 10:19 AM
Josh Hazel Josh Hazel is offline
Senior Contributor
 
Join Date: May 2008
Posts: 805
Default Excel VBA Form Move


I have Form1 and Form2. I want Form2 to always line up next to Form1, even after I move Form1 (especially after I move Form1).

Is there some kind of UserForm_Move event that I can use to have Left/Top always change to match the new location of the Form1?

Example code is appreciated. Thanks!
Reply With Quote
  #2  
Old 04-01-2009, 12:02 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline
Out Of Office

Retired Moderator
* Expert *
 
Join Date: Mar 2005
Location: London, UK
Posts: 3,398
Default

Hi,

Both userforms are shown modelessly?

Yes, you can do this - have a look at the userform's Layout event handler.

Hope that helps
Colin
__________________
RAD Excel Blog
Reply With Quote
  #3  
Old 04-01-2009, 04:26 PM
Josh Hazel Josh Hazel is offline
Senior Contributor
 
Join Date: May 2008
Posts: 805
Default

Quote:
Originally Posted by Colin_L View Post
Both userforms are shown modelessly?
Yes, you can do this - have a look at the userform's Layout event handler.
Yes both Modeless... still a bit new to the VBA (self taught, and im a sucky teacher) ... not sure what we mean about the Layout event handler? Do you have a link to a page I can read about it?

If Google = NoHelp Then PostHere = True
Reply With Quote
  #4  
Old 04-02-2009, 06:21 AM
Mill Mill is offline
Just another Excel nerd

Retired Moderator
* Guru *
 
Join Date: Feb 2000
Location: Michigan, USA
Posts: 2,626
Default

Quote:
Originally Posted by Josh Hazel View Post
Yes both Modeless... still a bit new to the VBA (self taught, and im a sucky teacher) ... not sure what we mean about the Layout event handler? Do you have a link to a page I can read about it?

If Google = NoHelp Then PostHere = True
Instead of a Form_Move event that occurs when a form is moved in Visual Basic, Excel VBA has a Userform_Layout event that occurs when you move an Excel userform.

Code:
Private Sub UserForm_Layout()

    Debug.Print Me.Top, Me.Left, Me.Height, Me.Width
    
End Sub
__________________
"The face of a child can say it all, especially the mouth part of the face." - Jack Handey
Reply With Quote
  #5  
Old 04-02-2009, 01:39 PM
Josh Hazel Josh Hazel is offline
Senior Contributor
 
Join Date: May 2008
Posts: 805
Default

Ahh yes that works perfect ... thanks!
__________________
Josh

If Google = NoHelp Then PostHere = True
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->