• Key board short cut (Word 97SR2)

    Author
    Topic
    #365864

    Is there a keyboard short cut to close all open windows in the VBA IDE except the IDE itself?

    Viewing 0 reply threads
    Author
    Replies
    • #565684

      If you close all the open windows, what’s left besides the menus?

      • #565790

        Ok, ok. I mean all open code and form and class mod windows. Not the Project Explorer or Immediate windows, etc.

        • #565822

          Kevin,

          I don’t know of a built-in shortcut. However…….

          This seems to work. I’m not sure why because I can do very little with cp, but hey.

          Sub CodePaneCloseVBE()
          For Each cp In Application.VBE.CodePanes
          Application.VBE.ActiveCodePane.Window.Close
          Next
          End Sub

          so you can run this from the application of your choice (excel for me, and no, I haven’t tested it in anything else) via menu or assigned shortcut. Not precisely what you want, I fear.

          so the next option is to call the sub from the immediate window – if you have it open all the time. You’d probably want to call the sub something like Sub C() if you go down that route and you of course have to have the code in an open workbook or document.

          so the next option is to modify the vbe menu’s. Which I believe requires Class modules. again, an always open workbook/document. I have done this with ripped code. I thought there was something about it here on the lounge but I’ve skimmed thru every post including “VBE” in it in VB/VBA/.NET and didn’t see it (Note to me: must go back through that list at some point). So if it wasn’t here it would most likely have been Chip or J-Walk. I’ll try and have a look for it but no promises!

          On the whole, from excel where I’ve almost always got a tools file open anyway, I’d prefer the second option. unless I run into someone else naming their subs after letters of the alphabet – but then I’d get ambiguous name alerts so it wouldn’t be too much of a problem, would it?

          • #565825

            Brooke,

            Thanks for that little routine. It works fine, but of course, running from the VBE is the ticket. I like your idea of naming it C and calling it from the Immediate window which is usually always open. So, I’ll use it there for now.

            But modifying the VBE menu is something I’d like to know how to do. I’ve looked for info on this in the past, but found nothing. Who or what are Chip and J-Walk? I’ll hit the net, but I’m sure chip will return snack food sites, etc. Can you update me on these? Thanks.

            • #565845

              I was about to say why don’t you know those, but they are excel sites, so maybe I’ll let you off.

              http://www.cpearson.com/

              http://www.j-walk.com/

            • #565848

              See what I miss looking at Word all day??

              Thanks for the links.

            • #567937

              (Edited by HansV to update link to Excel MVP site)

              Just wondering how you were getting on with this – I’ve only just started to play with it again myself. The link Sammy gives is good but you need to go in one link further to the http://www.cpearson.com/excel/vbemenus.htm%5B/url%5D page. I know this is all in excel but hey, it should work for you. An additional link on this subject is http://www.bmsltd.ie/O2000/Default.htm%5B/url%5D again in excel, you’re looking for the VBEtools2000 download – it should be translatable to word. Neither of these is actually what I vaguely remembered seeing before – I still haven’t rediscovered that – but they are both using the same method of class modules. The second link gives an alternative method of closing all the code panes different to the one I supplied as well as a few other interesting things

            • #568184

              Brooke,

              The links point to excellent resources. I’ve only started to test the Pearson approach. I’m hoping I don’t need the VBAE library reference for the production code. But I’ll give it a go sooner or later. It would be nice to add a button for the “close all code windows” and “clear the immediate window” function. Thanks for keeping me informed.

            • #569021

              I did a long search that opened just about every module and form in the project. With all those windows opened, I said to myself, “Hey, I’ll try Brooke’s C sub to close this beastly mess.” Guess what?

              “Object variable or with block variable not set.”

              Beats me…

            • #569086

              Hmmm. Working fine for me. What references have you got?

            • #569134

              Ah.

              Let me go off and stand in the corner for a bit – forms aren’t codepanes are they? doh blush

              From the above you will see that I’ve succesfully replicated your error message. Wasn’t that clever of me?

              Back to the drawing board.

              Sub please_work()
              Dim Pain As VBIDE.Window
              For Each Pain In Application.VBE.Windows
              If Pain.Type = vbext_wt_Designer Or Pain.Type = vbext_wt_CodeWindow Then Pain.Close
              Next
              End Sub

              You’ll need the extensibility reference set though, which I think you said you’d prefer not to have to do.

              Please tell me this works!

            • #569135

              Now you’r talkin’

              I’ll run this code in just a sec, but I think you nailed it. Hang on…

            • #569144

              You indeed nailed this one. I flavored it to run without the VBAE ’cause that’s just the way I am.

              Sub C() ‘CodePaneClose
              Dim wp As Object
              ‘Dim wp As VBIDE.Window
              For Each wp In Application.VBE.Windows
              Select Case wp.Type
              Case 0, 1 ‘ 0 = vbext_wt_CodeWindow : 1 = vbext_wt_Designer
              wp.Close
              End Select
              Next
              End Sub

            • #569145

              Your versions going in, I think. Can I go home now, please?

            • #569146

              Brooke,

              You may take the rest of the day off. Have a good weekend…

            • #565847

              Chip is Chip Pearson, http://www.cpearson.com/ and . J-Walk is John Walkenbach, http://j-walk.com/ss/%5B/url%5D Finally, http://www.mvps.org/links.html#Excel is the site to add to your favorites: it has links to the above and all of the rest of the MS Excel MVPs.

            • #565849

              Thanks, Sammy.

    Viewing 0 reply threads
    Reply To: Key board short cut (Word 97SR2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: