Excel planilha vba usf formulario desabilitando botao fechar

Seg, 29 de Novembro de 2010 18:26 Expedito Marcondes
Imprimir

Saberexcel - o site de quem precisa Aprender Macros Microsoft Excel VBA

Esses procedimentos e declarações do Aplicativo Microsoft Excel VBA, retiram o (X) de fechar o userform, você poderá usar isso para forçar o usuário a sair por um botão que o conduzirá a um outro lugar ou uma mensagem., baixe o exemplo, link no final da página.

INSIRA AS DECLARAÇÕES ABAIXO EM UM MÓDULO COMUM

Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Public Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_STYLE = -16
Public Const WS_SYSMENU = &H80000

Sub ChamarForm()
UserForm1.Show
End Sub

INSIRA OS PROCEDIMENTOS ABAIXO NA FOLHA DE CÓDIGO DO OBJETO USERFORM

Private Sub Label2_Click()
On Error Resume Next
ActiveWorkbook.FollowHyperlink "http://www.saberexcel.com.com/"
End Sub

Private Sub Label3_Click()
Link = "mailto:[email protected]"
On Error GoTo SbError
ActiveWorkbook.FollowHyperlink Address:=Link, NewWindow:=True '
Exit Sub

bError:
MsgBox "mensagem....... " & Link

End Sub

Private Sub UserForm_Initialize()

Dim hWnd As E_MarLong, lStyle As Long
If Val(Application.Version) >= 9 Then
hWnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hWnd = FindWindow("ThunderXFrame", Me.Caption)
End If
lStyle = GetWindowLong(hWnd, GWL_STYLE)
SetWindowLong hWnd, GWL_STYLE, (lStyle And Not WS_SYSMENU)


End Sub


Aprenda tudo sobre o Aplicativo Microsoft Excel VBA, sozinho, com os produtos didáticos - Saberexel - o site das macros



  Baixe o exemplo de planilha contendo o exemplo dos procedimentos e declarações acima
Excel planilha vba usf formulario desabilitando botao fechar (18.79 kB)

Tags:
Última atualização em Ter, 23 de Agosto de 2011 10:05