PC Review


Reply
Thread Tools Rate Thread

Closing VBE systematically

 
 
kjamison@travelers.com
Guest
Posts: n/a
 
      7th Feb 2008
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....


 
Reply With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      7th Feb 2008
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


<(E-Mail Removed)> wrote in message
news:8a447844-6c24-48c2-af86-(E-Mail Removed)...
>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....
>
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I systematically do this? JayPee Microsoft Excel Misc 3 14th Aug 2008 07:33 PM
Systematically add Records Through RecordsetClone Intui_Sol Microsoft Access Forms 2 16th Jan 2008 01:57 PM
Why is Microsoft systematically scanning my ports? Kai Windows Vista General Discussion 5 27th Dec 2007 04:03 AM
Systematically Renaming Ranges =?Utf-8?B?TVdT?= Microsoft Excel Programming 3 16th Feb 2006 03:11 PM
how to learn vba systematically lalaexcel Microsoft Excel Programming 1 16th Feb 2006 11:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 AM.