UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Hide Vbe Window, Office 2007    
 
   
Richard70
post Dec 28 2011, 03:40 PM
Post #1

UtterAccess Veteran
Posts: 450



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.
Go to the top of the page
 
+
timbailey
post Dec 28 2011, 05:02 PM
Post #2

UtterAccess Addict
Posts: 272



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.
Go to the top of the page
 
+
Richard70
post Dec 31 2011, 10:54 AM
Post #3

UtterAccess Veteran
Posts: 450



Thank you Tim!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 07:59 PM