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 / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Please, help!!! How to keep userform from being moved?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
boris - 13 Nov 2007 17:29 GMT
I can not find "movable" property for the form. So, how can i prevent user
from moving it around?
Thanks
gwoodby@gmail.com - 13 Nov 2007 17:54 GMT
> 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
gwoodby@gmail.com - 13 Nov 2007 18:05 GMT
On Nov 13, 11:54 am, gwoo...@gmail.com wrote:

> > I can not find "movable" property for the form. So, how can i prevent user
> > from moving it around?
[quoted text clipped - 56 lines]
>
> End Sub

Found it on the internet and it works,  :)
Chip Pearson - 13 Nov 2007 18:00 GMT
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 .

Signature

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

>I can not find "movable" property for the form. So, how can i prevent user
> from moving it around?
> Thanks
Tim Zych - 13 Nov 2007 18:04 GMT
Why would you need to prevent that? Is business logic dependent on the x,y
position of the top-left?

Signature

Tim Zych
SF, CA

>I can not find "movable" property for the form. So, how can i prevent user
> from moving it around?
> Thanks
boris - 13 Nov 2007 18:14 GMT
I am trying to prevent user from seeing the spreadsheet, so the form will
cover it up

> Why would you need to prevent that? Is business logic dependent on the x,y
> position of the top-left?
>
> >I can not find "movable" property for the form. So, how can i prevent user
> > from moving it around?
> > Thanks
Bill Renaud - 13 Nov 2007 19:24 GMT
<<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?

Signature

Regards,
Bill Renaud

 
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.