Full Version: Hide Vbe Window
UtterAccess Discussion Forums > Microsoft® Access > Access Macros
Richard70
Hi. I am building a macro through vba using the VBIDE object. When the .CreateEventProc method is fired, it opens the VBE window. Is there a way to keep this window closed while the code runs? Thanks.
timbailey
Chip Pearson pretty much shows the way to do this (for Excel) at http://www.cpearson.com/Excel/vbe.aspx . He uses a combination of the MainWindow.Visible property with the LockWindowUpdate API call.
Here is my port of his code to Access:
CODE
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long
Public Function EliminateScreenFlicker()
Dim VBEHwnd As Long, VBComp As VBIDE.VBComponent

On Error GoTo ErrH:

Application.VBE.MainWindow.Visible = False

VBEHwnd = Application.VBE.MainWindow.hwnd

If VBEHwnd Then
LockWindowUpdate VBEHwnd
End If

'''''''''''''''''''''''''
' Replace with your VBE code here
Set VBComp = Application.VBE.VBProjects(1).VBComponents.Add(vbext_ct_StdModule)
VBComp.Name = "NewModule"
'''''''''''''''''''''''''

Application.VBE.MainWindow.Visible = False

ErrH:
LockWindowUpdate 0&
End Function

I've added in "NewModule" as an example.
Richard70
Thank you Tim!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.