Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detecting if VB Editor is Open (xl2k VB6.0)

    Anyone know how to determine whether the VBEditor is visible or open?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting if VB Editor is Open (xl2k VB6.0)

    This detects an active VBE window:

    Option Explicit
    '*** Declare some Windows API calls

    Declare Function FindWindow32 Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Declare Function GetForegroundWindow Lib "user32.dll" () As Long

    Function IsVBEActive() As Boolean
    Dim hWndP1 As Long
    Dim hwndVBE as Long
    hWndVBE = Application.VBE.MainWindow.hwnd
    hWndP1 = GetForegroundWindow
    IsVBEActive = (hWndP1 = hWndVBE)
    End Function
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Detecting if VB Editor is Open (xl2k VB6.0)

    Jan,

    For me this code returns False unless the VBE is the foreground window, even though the window may be open.

    This seems to work :

    Dim IsVBEActive As Boolean
    IsVBEActive = Application.VBE.MainWindow.Visible.

    It returns True once the VBE window is open.

    Andrew

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting if VB Editor is Open (xl2k VB6.0)

    Yes, I knew. But I forgot to add it has to be the foreground window.

    Thanks for straightening this out.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •