• Compile Button in VBE (any)

    Author
    Topic
    #375793

    To keep this post from straying off topic, let’s jump here.

    Anothe nice touch to putting a Compile button on your VBE toolbar:

    If you set the button to display icon & text, the current project name displays
    next to the word “Compile”

    Viewing 0 reply threads
    Author
    Replies
    • #613095

      Anybody interested in custom toolbars and menus in the VBE?

      Wouldn’t it be nice to have a Clear Immediate button on the VBE toolbar?

      • #613146

        Well,

        If you want a VBA 6 (Office 2K or later) add-in that has a button that wil clear the immediate window, have a look at MZtools

        I have it on ALL the machines I develop on. Best part, it’s free!!

        There are SO many great features about this, I can’t list them all. Just have a look at it, and try it. You’ll like it as much as I do.

        No affiliation, other than an end user.

        • #613796

          Excellent tool. I’ve download and am testing. Thanks!

      • #613279

        didn’t we already do this one?

        • #613425

          I seem to recall we did. crazy Besides, all you need to do is click in the immediately window, do a Ctrl+A and then hit Del in order to clear the immediate window. That hardly requires a button. shrug

          • #613794

            boring…

            • #613911

              Busted! weep I have to admit it … my name is Charlotte and I can’t be bothered to build a button for that. laugh

            • #614065

              …humm, Charlotte. Friend of Wilbur?

        • #613795

          No, we wrote subs to clear the immediate window (none of which work consistently for some unknown reason). I don’t recall any posts about modifying the VBE toolbar to include a button to do it. My oversight if there was one.

          My interest back then was to include a call statement to clear the IW in a routine being debugged. It’s tedious having to click on the Immediate window, Ctrl-A, Del after every test run. Since the code to clear the IW doesn’t work, a toolbar button seems to be the next best thing.

          • #613912

            But if the code doesn’t work, what are you going to put behind the button? confused

            • #613928

              [indent]


              But if the code doesn’t work, what are you going to put behind the button? confused


              [/indent]
              This doesn’t seem to cause problems for other software developers. I have lots of code with toolbar buttons connected to nonsense!

              StuartR

            • #614061

              Well, Byan’s post about MZTools was just the post I was hoping for. That tool set has such a button.

              Maybe smarter programmers can write code that works!

              p.s. I’m not being critical of those who wrote the “old” code (I made an attempt, as did Andrew C. not sure who else) ’cause the code does work, but not always.

          • #613943

            Here’s a dumb question: How do you add a custom toolbar button in VBE? I don’t see any obvious way to do this when you open “Customize” dialog. For example, you once posted some code that closes all open code pane windows. I use this all the time, call sub using Tools “Macros” command, but it’d be cooler to use custom toolbar button for this. Any ideas??

            • #613974

              I just received this link, http://msdn.microsoft.com/library/default….ice07042002.asp[/url], in an e-mail from Microsoft this morning.

              Look about halfway down the page. There is a function called, AddCommandBarButtonToVBE

              I haven’t read it yet so no review, but I’m planning on reading it soon.

            • #614002

              Thanx for the links, I’ll check these out & try code when I get chance. But what I would like to know, since MS makes it simple to add custom buttons, menus, etc thru the UI, w/o any programming required, for application toolbars, why isn’t the same functionality provided for toolbars in VBE??

            • #614016

              It’s probably just one of those MSism we have all come to know and loath grin

            • #614063

              Mark,
              The simple answer to this is that the VBE toolbars are not a part of the Office object model. According to Chip Pearson, the VBE
              “… is based on the Visual Basic (Visual Studio) model, not the Office model. ” Translated, that means the VB dev team got lazy
              or ran out of time.

              I use the Steve Bullens idea (as Brooke mentioned) to create an event handler class. I got started with this page.

            • #614081

              [indent]


              The simple answer to this is that the VBE toolbars are not a part of the Office object model


              [/indent]Actually according to this page from Microsoft, it is part of the Office CommandBar Object, or at least that’s how I interperet it.

              Here is a copy and paste from the page:[indent]


              Working with command bars in the Visual Basic Editor is similar to working with command bars in the main Office applications. The Visual Basic Editor CommandBars object returns a reference to the Office shared components’ CommandBars collection. Remember to set a reference to the Microsoft Office 10.0 Object Library (if you’re using Microsoft Office XP) if it is not already set, or you will receive a User-defined type not defined error message if your code tries to access the CommandBars collection, command bar objects, or command bar control objects in the Office shared components object library.


              [/indent]

            • #614083

              That settles it then: lazy VB development team.

            • #614085

              Of course, in all fairness to those hard-working MS folks: maybe the VB5 code-base used Windows objects and later versions reference the Office shared objects???

              In Word 97, you need a reference to the VBA Extensions library. Looks like Office 10+ needs a reference to the Office 10 Object Library. My install of Office XP has that reference set by default.

              Updated after reading the msdn paged you referenced:

              “To access the Visual Basic Editor object model, you must first set a reference to the Microsoft Visual Basic for Applications Extensibility 5.3 type library.”

            • #614134

              I just tried it in both W97 (not that I don’t trust you Kevin smile. but I had to see for myself) and W2K and it didn’t work in either one. sad

              Same as Kevin, it adds the button, but doesn’t do a thing.

            • #614138

              That’s MS for you. Chip Pearson and Steve Bullens have it figured out. You need the events handler, period.
              Try my code based on gleanings from these two guys and others.

              Attached to this message is the code mod (rename .txt to .bas and import). Attached to the next message is the class mod.

            • #614140

              Rename .txt to .cls then import to the VBE.

            • #614141

              By the way, the Compile button I added via the code was just a programming exercise…

            • #614151

              I’m glad I’m not the only one that does things as programming exercises.

              I am currently working on a VBA “application” (hopefully it will work in Word, Excel, and any other VBA enabled application) to list ALL variables in a VBA Project. It started as a request from someone on a Word list I belong to, as a way to start to get a handle on how to work with the VBE, and it’s taken on a life of its own smile

            • #614152

              Would love to see it when it’s “palatable”.

            • #614158

              Well, If you want to see V1 RC2, you can get it from http://www3.sympatico.ca/carbonnb/dwt/index.html%5B/url%5D.

              It doesn’t handle Let/Get/Set properly and it misses conditionally compiled stuff properly at the moment. These are the areas I’m working on right now.

            • #615488

              I’ve done this in my ProcStripper – locate all deadwood procedures and delete them & locate unreferenced data/constant identifiers and mark them for deletion. Also sorts procedures by name within each module (for easy location using the PgUp key).

            • #614092

              Just for grins, I tried the MSDN code in Word 97. It adds the menubar item just fine, but click on it and nothing happens.

            • #614064

              Dumb question? Are you kidding? That’s an extremely intelligent question. See my other response to your post below. If you need any help after checking out my reference and the others mentioned, feel free to ask more questions.

              If you can figure out how to make this work consistently, I’d appreciate seeing the “ClearImmediate” code:

              Sub TestRoutine
              Call ClearImmediate
              Do
              AllSortsOfThingsToTestWhichWriteToThe(“Debug”, “Window”)
              Loop Until Done
              End Sub

            • #614181

              Thanx for additional info. I used MZ-Tools with VBE in Office 2K & worked good, the “Clear Immediate WIndow” button at any rate functioned as advertised. Have not used them in Office XP. So maybe I’ll just be lazy (like those lazy MS VB/VS dev guys) & download & install MZ-Tools – do they work OK with VBE in Office XP??

            • #614228

              I have them on my office machine (Win 2k/OXP) and haven’t had any problems.

            • #614267

              Since previous post I installed MZ-Tools on Office XP system & the add-in works fine w/no problems. I’d forgotten what a cool (and useful) product this is. I’d ask, why doesn’t MS incorporate many of these features in VBE, rather than having users resort to using 3rd-party add-ins, but that’d be another dumb question.

            • #613950

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

              I believe the only way to do this is programattically and to use a class module to trap the click events of the custom buttons. I just use Stephen Bullens VBEtools2000 as is, which is available from http://www.BMSLtd.ie[/url%5D. This is not locked so you can use it as a tuition for how to roll your own.

          • #614402

            Kevin,
            I’ve just been reading the Clear Immediate Window posts, which I must have missed the first time round, and it seems to me that if you’re going to use SendKeys, you might as well just use:
            SendKeys “^g^a{del}”
            Unfortunately this still doesn’t seem to work correctly if you call it to clear the window before printing some more stuff to it – at least in my test it removed everything including the new debug info!
            FWIW.

            • #614414

              Rory,

              Nice pic. Too bad we can’t embed mp3s in Lounge posts (oh yeah, right!). We’d all be searching for your posts just to get an Elvis fix (no pun intended) Heartbreak, Love Me, Blue Suede…

              I’ve tried various renditions of strings to pass to Sendkeys and the one published seemed the most consistent (besides, Andrew Connolly showed me this one).

              What’s happening for you is this: the immediate window does not have focus, so you are clearing one of your code windows!!

              I’ve also done extension testing with focus setting, using Sendkeys, the .setfocus method on the window object and API calls (getfocus, etc.)

              You’ve got to separate the ^g (setting the focus) from the ^a{del}. Not sure why, but it’s obvious the ^g is not working (or at least is inconsistent).

              By the way, this much is conclusive:

              Calling a ClearImmediate sub from another sub simply does not work.
              But calling the ClearImmediate sub from a VBE command button works every time!

              –AND YES, CHARLOTTE, IT’S THE EXACT SAME CODE (NO SUPERIOR PROGRAMMER REQUIRED)

              Interestingly, when creating the button, you can indicate an accelerator key. Executing
              the commandbutton by pressing the accelerator key — DOES NOT WORK!

              I suspect this inconsistency is all due to “focus” issues. Maybe sending keystrokes to the
              window using an API call might work.

    Viewing 0 reply threads
    Reply To: Compile Button in VBE (any)

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

    Your information: