IntroductionGetting StartedAll PostsNotesAbout The Author
Controling The VBE
Friday, September 25, 2009 - 1:43 PM
This is useful for hiding the VBE after code stops (do to a "Stop" statement, because the user interrupted the code, or because of an error).


Public
gvTestVBEAccess As Boolean


Public Function HideVBE()
    On Error Resume Next
    If fTestVBEAccess Then Application.VBE.MainWindow.Visible = False
End Function


Private Function fTestVBEAccess()
As Boolean
'returns true if the project isn't locked
'uses gvTestVBEAccess public boolean for sake of speed
    If gvTestVBEAccess Then fTestVBEAccess = True: Exit Function
    On Error Resume Next
    Dim vbp As VBProject: Set vbp = ThisWorkbook.VBProject
    If (vbp.Protection <> vbext_pp_locked) Then gvTestVBEAccess = True: fTestVBEAccess =
True
End Function


Example usage:
Stop: HideVBE
<< Navigate to Friday, September 25, 2009 Add New Comment
No records found        
Add New Comment
Your name   
Subject   
Content   
*Required fields

January, 2009
February, 2009
March, 2009
April, 2009
May, 2009
June, 2009
July, 2009
August, 2009
September, 2009
October, 2009
November, 2009
December, 2009
IntroductionGetting StartedAll PostsNotesAbout The Author