When I first starting really getting into VBA, it was pretty invaluable to me to be able to read over my code. And over and over and over my code again. And again. As well as others code. This really helped me learn the syntax and flow. An add-in which was great, which I can’t remember the name of, allowed me to print out my VBA code as an HTML file, so I could view the code as it looked in the VBIDE. This was great! I could now review my code and keep it as a hard copy for backup!
In the meantime, I have done a lot of posting to forums of sorts. One of the forums in particular is Mr Excel.com. This board utilizes vBulletin software and is laid out very nicely. There are a few add-ins to help you post things to make it present nicely when viewed. Some of these add-ins were (a list of which can be found here) Colo’s HTMLMaker, Excel Jeanie 4, ASAP Utilities, etc. Among these was the VBHTMLMaker add-in, which let you post your VBA code to the forum and have it present as it did in the IDE. Awesome!
So now to my point. A few years ago I asked Juan Pablo González, original developer of the VBHTMLMaker add-in (amongst other collaborators) if I could amend his add-in. What I wanted to do was add an option to save the HTML generated code into an HTML file. Easy, portable, documented, and printable! He graciously agreed and that’s where I sat until yesterday. I made excuses that I didn’t have time, but more or less I didn’t make it a priority. I finally had enough with my procrastination and I added the code yesterday, tested today, and am now uploading to share with the world.
There is also some minor modifications to keep it as the font you have set in your VBE options. To get this value we need to read the registry, which retains the font name (among properties). A portion of the code was graciously utilized from Dev Ashish and Terry Kreft. This is used by the following code:
‘ Txt = IIf(HTML, ““, “[face=Courier New]“)
Txt = IIf(HTML, ““, “[face=Courier New]“)
If you do not want to use such code and want it in Courier New every time, uncomment the commented line and take out the other. Unfortunately this only works for HTML and not BB code. The new file is named VBHTMLMaker2007, but does not utilize the Ribbon in any way. So if you have a need or desire to save your VBA as an HTML file for whatever reason, this file has the amended code as such. Enjoy!