• VBA Editor Tool to Add/Remove Line Numbers? (VBA)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » VBA Editor Tool to Add/Remove Line Numbers? (VBA)

    Author
    Topic
    #360005

    Does any one know of any addin that enables you to add/remove line numbers in your code from within the VBA editor? I find this feature invaluable in locating the line number where an error occurs after code is sent out. There’s a great VB6 addin called CodeSmart which does this kind of thing, but is doesn’t work in VBA.

    Viewing 1 reply thread
    Author
    Replies
    • #541118

      I take it you manually enter the line numbers then use the hidden, undocumented erl() function in your error routine to tell you the line number, correct?

      I’ve been working on a sub specific routine that will display the list of subs/functions in a module and allow you to apply line numbers to selected subs. It could be modified to just apply the line numbers to an entire project, but I’m not ready for that…

      …because I have no code *yet* to remove the line numbers. Ha!

      • #541148

        Kevin–
        Thanks for the response. Yes, I use the erl in my error routine; it’s helped me track down a lot of problems from afar. As for inserting/removing the line numbers, sometimes I do it manually, and sometimes, when I’ve got a spare moment, I just copy the whole module into a VB project and let CodeSmart do its thing. I started writing an addin to do this stuff too, but kept on getting pulled away from it by more pressing matters (like my boss wanting additional features, etc.)

        Dan

    • #541323

      I found a VBA add-in that adds line numbers to your code.I haven’t used it yet and forgot about it until I saw your post. I just now installed it but haven’t run it yet. I don’t remember where I got it but I was thrilled to see any add-in for VBA as there are so few. Here is part of the readme file:

      – Line Numbering Utilities is a true Microsoft Office COM add-in
      developed in Visual Basic for Applications 6.0. (VBA) and designed for
      the Visual Basic Editor (VBE).

      – Line Numbering Utilities is designed to help VBA developers to
      easily add/remove line numbers to their Microsoft Office VBA projects.
      (Microsoft Office 2000 and XP)

      – The VBE environment is unchanged from its default settings, aside from
      the Line Numbering Utilities menu item added under the Add-ins menu.

      Deb thumbup

      • #541370

        Can you attach a URL to where you found it?

        • #541374

          Geoff W. Added hyperlinks

          Up until now I never bothered to install the thing so I had to do that first before I could answer this question. I already sent the .zip file to the original poster and he’s going to report back on how well it works. I didn’t have a need for it at the time but there are so very few VBA add-ins that I just downloaded to see what it’s like. I found the URL in the about box:

          http://www.siam-consulting.com/Downloads.htm

          They offer two cool tools: 1) Commandbar Controls ID Browser, and 2) Line Numbering Utilities.

          I installed and ran the Line Numbering tool and it seemed to work just fine.

          Enjoy, Deb joy

          • #543547

            Deb–

            Sorry it’s taken a while to get back on this. I tried the line numbering tool, but ran into some problems. It seems to add the numbers okay, but, at least in Word 2000, it doesn’t remove them, even though it says it has.

            Dan

            • #543549

              OOOOOHHHHHhh, you didn’ say you want to “remove” the line numbers as well sarcasm

              I only tried it in Excel but I didn’t save the workbook with the numbers so don’t know if the numbers couldn’t be removed. I’d write the people who created it as from the one e-mail I got from them the seemed very helpful. I’m sure they intended to write a program that let you remove the numbers as well.

              I’m glad it worked for you (sort of).

              Deb flee

            • #543636

              VBACodePrint is a VBA add-in that allows you to print your code with or without line numbers. You don’t have to add them anywhere, the add-in does it when it formats the code for printing. You can find it at http://www.jn-software.com/. There are actually versions for VB, VBA, SQL Server, etc., and none of them is very expensive. If have it for both VB and VBA, and it works very well.

            • #543660

              Actually I think the originator wanted line numbers for debug purposes not for printing per se. It was to be used when an error is triggered so he knows exactly what line caused it. The tool I told him about is a VBA control that worked just fine to add the numbers but he said he couldn’t see how to remove them later. I only tried to add the numbers in Excel, whereas he’s using Word.

              But, VBACodePrint is a nice utility to have as well..

              Deb grin

    Viewing 1 reply thread
    Reply To: VBA Editor Tool to Add/Remove Line Numbers? (VBA)

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

    Your information: