Hi everyone,
I'm wondering if it is possible to prevent the user from moving form on screen.
How can it be done without using the UserForm_Layout event which flicks the screen...
Many thanks.
Hi everyone,
I'm wondering if it is possible to prevent the user from moving form on screen.
How can it be done without using the UserForm_Layout event which flicks the screen...
Many thanks.
Why do you want to prevent the userform being moved?
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Hello Memphis,
It requires using API calls. Here is the macro code. Load this into a Standard VBA module. Add the command LockPosition to the UserForm_Activate code procedure.
Adding the Macro![]()
'Written: October 09, 2007 'Author: Leith Ross 'Summary: Prevents a UserForm from being moved. Add LockPosition to the ' UserForm_Activate event procedure. Private Const MF_BYCOMMAND As Long = &H0 Private Const SC_MOVE As Long = &HF010 Public Declare Function GetSystemMenu _ Lib "user32.dll" _ (ByVal hWnd As Long, _ ByVal bRevert As Long) As Long Private Declare Function DrawMenuBar _ Lib "user32.dll" _ (ByVal hWnd As Long) As Long Private Declare Function DeleteMenu _ Lib "user32.dll" _ (ByVal hWnd As Long, _ ByVal nPosition As Long, _ ByVal uflags As Long) As Long Private Declare Function GetForegroundWindow _ Lib "user32.dll" () As Long Public Sub LockPosition() Dim hMenu As Long Dim hWnd As Long Dim Ret As Long hWnd = GetForegroundWindow() hMenu = GetSystemMenu(hWnd, 0&) Ret = DeleteMenu(hMenu, SC_MOVE, MF_BYCOMMAND) Ret = DrawMenuBar(hWnd) End Sub
1. Copy the macro above pressing the keys CTRL+C
2. Open your workbook
3. Right Click on any Sheet's tab
4. Left Click on View Code in the pop up menu
5. Press the keys ALT+I to activate the Insert menu
6. Press M to insert a Standard Module
7. Paste the code by pressing the keys CTRL+V
8. Make any custom changes you need to the macro
9. Save the Macro by pressing the keys CTRL+S
Sincerely,
Leith Ross
Thanks Leith Ross, it worked fine!!!!
Thank you royUK for your interest too...
Keep working.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks