Results 1 to 8 of 8

Thread: Trace (VBA/All)

  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Trace (VBA/All)

    Back in the dark ages when Basic was first released and every line required a unique number identifier, there was a feature called Trace, This feature identified the line number of each command that was run, each time it was run.

    Over the past few months, I have experienced several occasions where an add-in would behave unexpectedly, yet when stepped through, all went as advertised. An ideal opportunity to use Trace. I could find no reference to it. So! I made my own. The attached text file contains the code to insert line nuimbers between each command; as well as the code to remove them. To operate:
    1. <LI>Place the suspect code into an empty Word document
      <LI>Run the Tracing procedure on the code
      <LI>Place the revised code back into your project
      <LI>Donj't forget to compile the code; just in case there are debug commands where they don't belong.
      <LI>Run your project. The line numbers at the point of termination and about 100lines previous will be printed out.
    To remove the tracing code:

    1. <LI>Place the code in an empty Word document
      <LI>Run the UnTrace procedure
      <LI>Place the revised code back into your project
      <LI>Donj't forget to compile the code; just in case there are debug commands where they don't belong.
    FWIW
    Regards
    Don

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Trace (VBA/All)

    Don,
    I don't know if you were aware of it, but if you put line numbers in your code, you can then use the <code>Erl</code> function in an error handler to output the line numebr where it all went wrong.
    NDT
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Trace (VBA/All)

    Thanks Rory
    Erl is new to me. I certainly will familiarize myself with it.

    Is there an automated method within VBE to number: existing code? code as it is entered?

    BTW; I dreamed up this Trace feature because I had an instance of the anti-virus software terminating the macro. No error message or warning from VBA; just a flag from the AV software.

    Thanks for the input.
    Regards
    Don

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Trace (VBA/All)

    Not that I know of but I am sure I have seen an add-in that does it - possibly MZ Tools, which I unfortunately do not have at work.
    Was the AV McAfee? (I <big>HATE</big> McAfee because at work when I export certain code modules, it just deletes them!)
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Trace (VBA/All)

    MZ Tools does have line numbering (and with more control than some other add-ins I've seen)

    You can also 'boilerplate' your error-handling code from within MZ Tools as well.

    I cannot recommend it too highly.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  6. #6
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Trace (VBA/All)

    No it wasn't McAfee it was Proventia BlackIce.
    <hr>when I export certain code modules, it just deletes them<hr>
    When ever I need to e-mail code I export it from VBE as a .txt file; this way they get through the AV gates; and can be imported into VBE either by File | Import or Drag and Drop .
    Regards
    Don

  7. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Trace (VBA/All)

    That doesn't work with McAfee (at least not the version we have) - if you export the module, no matter what as, it gets deleted. No prompts, no options, just gone. And I then get the IT department ringing me up asking me what I'm doing. Only one party enjoys that conversation! <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Regards,
    Rory

    Microsoft MVP - Excel

  8. #8
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Trace (VBA/All)

    Thanks Steve
    Regards
    Don

Posting Permissions

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