Notifications
Clear all

Como fechar o Windows Explorer pelo VBA Excel

3 Posts
2 Usuários
0 Reactions
957 Visualizações
(@joaoguilhe)
Posts: 4
New Member
Topic starter
 

Boa noite a todos!

Peço uma ajuda, por favor!

Como faço para fechar o windows explorer pelo VBA Excel?

Para abrir o windows explorer estou utilizando o comando shell, mas a operação inversa eu desconheço.

Alguém pode me orientar?

Grato

João Guilherme

 
Postado : 27/11/2015 4:49 pm
Fernando Fernandes
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Bom dia!!

Veja:
http://allapi.mentalis.org/apilist/FindWindow.shtml

Tente criar uma função (API)

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
 
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
 
Private Const WM_CLOSE As Long = &H10
 
Private Sub Command1_Click()
    Dim lHwnd As Long
    lHwnd = FindWindow("CabinetWClass", "Mapa do driver")
    PostMessage lHwnd, WM_CLOSE, 0&, 0&
End Sub
'----------Outro---------------------
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long
Declare Function SendMsg Lib "user32" Alias "SendMessage" (ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Sub CloseIt()
   Dim WM_Close As Long
   Dim WinHandle As Long
   Dim WM_SYSCOMMAND As Long
   WM_SYSCOMMAND = &H0112
   WM_Close = &HF060
   WinHandle = FindWindow(CLng(0),"Disco Local (C:)")
   SendMsg(WinHandle,WM_SYSCOMMAND,WM_Close,CLng(0))
   FreeLibrary("user32.dll" )
End Sub

Att

Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel

 
Postado : 28/11/2015 6:46 am
(@joaoguilhe)
Posts: 4
New Member
Topic starter
 

Vou tentar fazer aqui.
Obrigado!

 
Postado : 29/11/2015 5:10 am