Edu
13-05-2011 17:24:57
Teria com desabilitar o botao fechar do excel?
Edu
13-05-2011 17:24:57
Mauro Coutinho
13-05-2011 23:38:40
Código: Selecionar todos
Private Sub Workbook_Open()
Application.ScreenUpdating = False
RetirarMenuControle32
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
AplicarMenuControle32
End Sub
Código: Selecionar todos
Option Explicit
Declare Function FindWindow32 Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
Declare Function GetWindowLong32 Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer) As Long
Declare Function SetWindowLong32 Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer, _
ByVal dwNewLong As Long) As Long
Global Const GWL_STYLE = (-16)
Global Const WS_SYSMENU = &H80000
Sub AplicarMenuControle32()
Dim WindowStyle As Long
Dim hWnd As Integer
Dim WindowName As String
Dim Result As Variant
WindowName = Application.Caption
hWnd = FindWindow32(0&, ByVal WindowName)
WindowStyle = GetWindowLong32(hWnd, GWL_STYLE)
WindowStyle = WindowStyle Or WS_SYSMENU
Result = SetWindowLong32(hWnd, GWL_STYLE, WindowStyle)
ActiveSheet.Activate
End Sub
Sub RetirarMenuControle32()
Dim WindowStyle As Long
Dim hWnd As Integer
Dim WindowName As String
Dim Result As Variant
WindowName = Application.Caption
hWnd = FindWindow32(0&, ByVal WindowName)
WindowStyle = GetWindowLong32(hWnd, GWL_STYLE)
WindowStyle = WindowStyle And (Not WS_SYSMENU)
Result = SetWindowLong32(hWnd, GWL_STYLE, WindowStyle)
ActiveSheet.Activate
End Sub