Programmatically close the Visual Basic Editor window in Access 2000.
Application.VBE.MainWindow.Visible = False
An alternative approach would be to locate the handle to the window, and if
found, send it a request to close itself.
This code sample shows you how to implement the alternative mentioned
above.
Private Const WM_CLOSE = &H10
Private Declare Function apiPostMessage _
Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Declare Function apiFindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Private Declare Function apiIsWindow _
Lib "user32" Alias "IsWindow" _
(ByVal hwnd As Long) _
As Long
Function fCloseVBEWindow() As Boolean
' Closes the VBE window if it's currently open
'
Const VBE_CLASS = "wndclass_desked_gsk"
Dim hwnd As Long
hwnd = apiFindWindow(VBE_CLASS, VBE.MainWindow.Caption)
If hwnd Then
Call apiPostMessage( _
hwnd, _
WM_CLOSE, _
0, _
ByVal 0&)
fCloseVBEWindow = (apiIsWindow(hwnd) <> 0)
End If
End Function |