![]() |
Closing VBE systematically
I have an app - where I am creating another spreadsheet with pivot
tables on it, then adding command buttons and programatically putting code behind those buttons. When this is done - the VBE window is opened - which I would like to close systematically. I can hide it using the following code which works. Application.VBE.MainWindow.Visible = False But if I put in the exact same place the following code to close it - it bombs. Application.VBE.MainWindow.Close The error I get is "Run-time error '-2147467259 (80004005)':" "System Error &H80004005 (-2147467259). Unspecified error" Thanks for any help you can provide.... |
Closing VBE systematically
Try this one, all in a normal module:
Option Explicit Private Declare Function FindWindow _ Lib "user32" Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function PostMessage _ Lib "user32" Alias "PostMessageA" _ (ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Private Const WM_CLOSE = &H10 Sub CloseVBE() PostMessage FindWindow("wndclass_desked_gsk", vbNullString), _ WM_CLOSE, 0&, 0& 'to cancel the close WB dialog SendKeys "{ESC}", True DoEvents End Sub RBS wrote in message ... I have an app - where I am creating another spreadsheet with pivot tables on it, then adding command buttons and programatically putting code behind those buttons. When this is done - the VBE window is opened - which I would like to close systematically. I can hide it using the following code which works. Application.VBE.MainWindow.Visible = False But if I put in the exact same place the following code to close it - it bombs. Application.VBE.MainWindow.Close The error I get is "Run-time error '-2147467259 (80004005)':" "System Error &H80004005 (-2147467259). Unspecified error" Thanks for any help you can provide.... |
All times are GMT +1. The time now is 02:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com