Results 1 to 6 of 6

Thread: closing VBE windows programatically...[resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Resolved closing VBE windows programatically...[resolved]

    can i close these windows without the exact caption ?
    if not how do i find it ?
    i want to wind up with an empty VBE gray screen, just the menu bar & tools...

    ...this works..but i cheated...
    VB Code:
    1. Application.VBE.Windows("Project - STOCKBOOK").Close
    2.     Application.VBE.Windows("Properties - Module18").Close
    Last edited by MJBNET; Apr 7th, 2005 at 08:00 PM. Reason: reesolved

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: closing VBE windows programatically...

    You can use the index number instead of the name.
    VB Code:
    1. Application.VBE.Windows.Item(1).close
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Re: closing VBE windows programatically...

    thankx man...i applied it in this code and so far perfect...gray screen and all !!
    if ya see any potential flaws...lemme know...txx again
    VB Code:
    1. Dim idx As Integer
    2.    
    3.     Application.VBE.MainWindow.Visible = True
    4.     Application.VBE.MainWindow.SetFocus
    5.    
    6.     Do Until InStr(1, Application.VBE.activewindow.Caption, "[running]") <> 0
    7.         Application.VBE.activewindow.Close
    8.     Loop
    9.    
    10.     idx = 0
    11.     Do Until idx = Application.VBE.Windows.Count
    12.         idx = idx + 1
    13.         Application.VBE.Windows.Item(idx).Close
    14.     Loop
    15.    
    16.     Application.VBE.CommandBars("Menu Bar").Controls("Tools").SetFocus
    17.     SendKeys "~"
    18.     SendKeys "~"

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: closing VBE windows programatically...[resolved]

    Looks ok but what are you trying to accomplish? Looks like it just closes the VBA IDE.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Re: closing VBE windows programatically...[resolved]

    yes it's a work around to deal with this situation:

    we put a workbook from one comp to another.
    then remove broken refs if any...
    ---Application.VBE.ActiveVBProject.References.Remove ref---
    why do this ? ... i found a workbook can have refs it does not need...But it will cause an error in a procedure that has nothing to do with that library...ie.. you'll get an error on the "UCase" function for a broken ref to some totally unrelated lib...
    Now ya think ---Application.VBE.ActiveVBProject.References.Remove ref--- would fix that...but because the ref never existed on that comp...it generates ar runtime error [-2147319779 object library not registered]........so we open the reference window ...let the user untick the missing ref...
    ..and to finally answer why close all IDE ...simply 'cause it's less confusing if there is nothing behind the references window but a peacefull gray screen...

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: closing VBE windows programatically...[resolved]

    Ok, now I see where all this fits in.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width