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

    code Structure highlighting (Excel 2000 and up)

    Hi everyone,

    I've been contriving a utility that can highlight entire clauses in the VBE so you can highlight all lines that belong to one of these structures:

    function ... end function
    sub ... end sub
    do ... loop
    for ... next
    if ... end if
    select ... end select
    while ... wend
    with ... end with

    Would anyone of you

    a. use it
    b. like to test it?
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code Structure highlighting (Excel 2000 and up

    Hah! I wrote this sort of thing about four years ago. I have a utility application called "Nestr" which re-indents (hence Nests) VBA code. It's supposed to be rules-driven, that is, it runs on a set of rules that define just which code structures are nestable, and hence can do VBA, Algol, PL-1 etc. I'll dig it up and compare notes.

    I use it daily on my code, and ought to be adding a rule for Type/End Type, which i didn't use back in 2000.

    If you'd like a copy of nestr040.dot ......

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

    Re: code Structure highlighting (Excel 2000 and up

    Mine doesn't do indenting, for that I use Stephen Bullen's excellent Smart indenter: http://www.oaltd.co.uk/Indenter/Default.htm
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code Structure highlighting (Excel 2000 and up)

    Believe it or not, that's a difficult one for me to answer Jan. In terms of willingness and appeal, I'd answer YES to both a) and [img]/forums/images/smilies/cool.gif[/img]. But in terms of knowing how easily I slip into bad habits, when something else does the work for me, I'd have to sit on the fence.

    Even so, I'd certainly be willing to test it, bearing in mind that my bursts of Basic are just that - sporadic and intense, as dictated by the demands of that which is beyond my mere mortal control (bosses whims <img src=/S/grin.gif border=0 alt=grin width=15 height=15> ).

    Alan

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code Structure highlighting (Excel 2000 and up

    Thanks for the link. Here's my "rules table" for VBA.
    col1: tag to recognise
    col2: indentation to apply
    col3: tag(s) that terminate this structure
    col4: whether to "re-push" an entry (useful with ElseIf like structures)
    col5: indentation to remove.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: code Structure highlighting (Excel 2000 and up)

    I have to admit extreme stupidity, for I can't get the Tools | Highlight Statement menu option in the VBE to do anything but generate an error message (see below). What am I supposed to do?

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

    Re: code Structure highlighting (Excel 2000 and up)

    There is a problem in it that when you once use it whilst in the declaration area, it refuses to recognise anything. I suspect a bug in the VBE IDE.

    Restart Excel end try it while your cursor is on any line that contains either an opening keyword or a closing one (so either If or End If, For or Next, ...)
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: code Structure highlighting (Excel 2000 and up)

    That must have been my mistake. It's a really annoying bug!

Posting Permissions

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