ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Keep VBA window hidden (https://www.excelbanter.com/excel-programming/350657-keep-vba-window-hidden.html)

jgeniti

Keep VBA window hidden
 
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").Co deModule
StartLine = .CreateEventProc("BeforeDoubleClick", "Worksheet") + 1
.InsertLines StartLine, "PurchasePartsDblClick"
End With


Kris

Keep VBA window hidden
 
JGeniti wrote:
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").Co deModule
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&


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com