Full Version: Hide Vbe Window
UtterAccess Discussion Forums > Microsoft® Access > Access Macros
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.
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:
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

LockWindowUpdate 0&
End Function

I've added in "NewModule" as an example.
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.