VBIDE - Visual Basic for Applications Extensibility 5.3
I am intrigued by the idea of writing code that will report on or edit existing code. Unfortunately I am yet to master the use of VBIDE - my skill level on this is currently little-to-none.
So every so often, I post a new VBIDE challenge hoping that some forum user will solve it for me (either from kindness and/or for the love of the challenge).
Here's challenge #6.
Can we use VBIDE to convert a project from one coding style to another?
In this challenge we are looking at Dims. Some coders prefer to declare these just before they are used, others prefer to place them at the top of the procedure.
[UPDATE - This challenge beaten by romperstomper] Loop through every procedure in ThisWorkbook (with the exception of the VBIDE module) and move any Dim found to the top ( .ProcBodyLine ?) of that procedure. Unskilled though I am, I think this is doable. I'm guessing it would be a good idea to loop from the bottom of each module upwards.
[UPDATE - This challenge beaten by romperstomper] The only drawback I can see would be the Dims would be placed before any comment lines at the top of the procedure. So extra points if you can detect comment lines at the top of a procedure and move the procedural Dims below these.
[UPDATE - This challenge not beaten yet] P.S. For anyone looking for an even more advanced challenge - try converting to the Just In Time coding method. Any Dims in a procedure are moved to the line before the first instance they are used in that procedure.
Bookmarks