Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Please, help!!! How to keep userform from being moved?

I can not find "movable" property for the form. So, how can i prevent user
from moving it around?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Please, help!!! How to keep userform from being moved?

On Nov 13, 11:29 am, boris wrote:
I can not find "movable" property for the form. So, how can i prevent user
from moving it around?
Thanks


*** Place this code In a User Form ***

Option Explicit

Private Sub UserForm_Initialize()

Call RemoveCaption(Me)

End Sub

*** Place this code In a Module ***

Option Explicit

Private Declare Function FindWindow Lib "User32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function GetWindowLong Lib "User32" _
Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "User32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Declare Function DrawMenuBar Lib "User32" ( _
ByVal hwnd As Long) As Long

Sub RemoveCaption(objForm As Object)

Dim lStyle As Long
Dim hMenu As Long
Dim mhWndForm As Long

If Val(Application.Version) < 9 Then
mhWndForm = FindWindow("ThunderXFrame", objForm.Caption) 'XL97
Else
mhWndForm = FindWindow("ThunderDFrame", objForm.Caption)
'XL2000+
End If
lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not &HC00000
SetWindowLong mhWndForm, -16, lStyle
DrawMenuBar mhWndForm

End Sub

Sub ShowForm()

UserForm1.Show False

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Please, help!!! How to keep userform from being moved?

There is no simple way to do this. Which begs the question, why would you
want to prevent the user from moving the form? Personally, I would not
appreciate it if some program locked up display positions.

If you want the form top open at a particular location, such as next to a
specific cell, see the code at
http://www.cpearson.com/Excel/FormPosition.htm .

If you want to keep the form within the bounds of the main Excel window or
the window of a workbook, see the code at
http://www.cpearson.com/Excel/SetParent.aspx .

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"boris" wrote in message
...
I can not find "movable" property for the form. So, how can i prevent user
from moving it around?
Thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Please, help!!! How to keep userform from being moved?

Why would you need to prevent that? Is business logic dependent on the x,y
position of the top-left?

--
Tim Zych
SF, CA

"boris" wrote in message
...
I can not find "movable" property for the form. So, how can i prevent user
from moving it around?
Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Please, help!!! How to keep userform from being moved?

On Nov 13, 11:54 am, wrote:
On Nov 13, 11:29 am, boris wrote:

I can not find "movable" property for the form. So, how can i prevent user
from moving it around?
Thanks


*** Place this code In a User Form ***

Option Explicit

Private Sub UserForm_Initialize()

Call RemoveCaption(Me)

End Sub

*** Place this code In a Module ***

Option Explicit

Private Declare Function FindWindow Lib "User32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function GetWindowLong Lib "User32" _
Alias "GetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "User32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Declare Function DrawMenuBar Lib "User32" ( _
ByVal hwnd As Long) As Long

Sub RemoveCaption(objForm As Object)

Dim lStyle As Long
Dim hMenu As Long
Dim mhWndForm As Long

If Val(Application.Version) < 9 Then
mhWndForm = FindWindow("ThunderXFrame", objForm.Caption) 'XL97
Else
mhWndForm = FindWindow("ThunderDFrame", objForm.Caption)
'XL2000+
End If
lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not &HC00000
SetWindowLong mhWndForm, -16, lStyle
DrawMenuBar mhWndForm

End Sub

Sub ShowForm()

UserForm1.Show False

End Sub


Found it on the internet and it works, :)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Please, help!!! How to keep userform from being moved?

I am trying to prevent user from seeing the spreadsheet, so the form will
cover it up

"Tim Zych" wrote:

Why would you need to prevent that? Is business logic dependent on the x,y
position of the top-left?

--
Tim Zych
SF, CA

"boris" wrote in message
...
I can not find "movable" property for the form. So, how can i prevent user
from moving it around?
Thanks




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Please, help!!! How to keep userform from being moved?

<<I am trying to prevent user from seeing the spreadsheet, so the form will
cover it up.
Why not just hide the worksheet, until the form is dismissed?

--
Regards,
Bill Renaud



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing a cell even if its contents are moved moved/replaced Darren Excel Discussion (Misc queries) 7 May 22nd 10 08:43 PM
worksheet to be moved jayesh trivedi Excel Discussion (Misc queries) 1 February 8th 09 10:18 AM
Moved cell & Ref Karen53 Excel Programming 2 November 2nd 07 11:18 PM
Data Validation If statement moved to userform thom hoyle Excel Programming 5 May 12th 05 08:04 PM
Doesn't work when moved. Lee Hunter Excel Programming 6 September 9th 04 09:47 PM


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"