View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Blocking Access to Sheet

Hi,

This is some code I kept written by Ivan F Moala that disable the option to
move a userform

Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As
String, _
ByVal lpWindowName As String) As Long
Private Const MF_BYPOSITION As Long = &H400

Private Sub UserForm_Initialize()
Dim lFrmHdl As Long, iCount As Integer
lFrmHdl = FindWindowA(vbNullString, Me.Caption)
If lFrmHdl < 0 Then
For iCount = 0 To 1
RemoveMenu GetSystemMenu(lFrmHdl, False), 0, MF_BYPOSITION
Next iCount
End If
End Sub

Mike

"Eddie_SP" wrote:

Hi Community !

I have in my initial UserForm the following code to take all the screen:

Me.Height = Application.Height
Me.Width = Application.Width

BUT,

I've realized that users can move this UF and change the sheets with all
data behind it.

Is there any code I can use to "lock" this UserForm? So people cannot move it?

Thank yoooou !