Keep VBA window hidden

J

JGeniti

Hi guys.
I'm trying to add an event procedure to my VBA code and I am unable to
supress the VBA window from opening when the macro runs.
I have tried turning off screen updating and making sure that the VBA
window is closed but it still opens when it runs.
Any help would be appreciated.
Thanks
James


Application.ScreenUpdating = False
Application.VBE.MainWindow.Visible = False
With ActiveWorkbook.VBProject.VBComponents("Sheet7").CodeModule
StartLine = .CreateEventProc("BeforeDoubleClick", "Worksheet") + 1
.InsertLines StartLine, "PurchasePartsDblClick"
End With
 
K

Kris

JGeniti said:
Hi guys.
I'm trying to add an event procedure to my VBA code and I am unable to
supress the VBA window from opening when the macro runs.
I have tried turning off screen updating and making sure that the VBA
window is closed but it still opens when it runs.
Any help would be appreciated.
Thanks
James


Application.ScreenUpdating = False
Application.VBE.MainWindow.Visible = False
With ActiveWorkbook.VBProject.VBComponents("Sheet7").CodeModule
StartLine = .CreateEventProc("BeforeDoubleClick", "Worksheet") + 1
.InsertLines StartLine, "PurchasePartsDblClick"
End With


Sceen updating works only on Excel windows.
You can't hide VBE windows, but you can freeze it.



Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock
As Long) As Long



ActiveWorkbook.VBProject.VBE.MainWindow.SetFocus
LockWindowUpdate Application.VBE.MainWindow.Hwnd


your code


Application.VBE.MainWindow.Visible = False

LockWindowUpdate 0&
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top