Posting Code to this Blog

For years I’ve been typing <code> tags and pasting code between them. But no more! I wrote a small utility that puts the code tags around my code and pops into the clipboard. Think of the seconds that I’ll save.

There are three situations that I wanted to cover with this code; no selection, multiple procedure selection, and intra-procedure selection. If there’s no selection, I want the whole procedure that contains the cursor. If the selection spans more than one procedure, I want the entirety of all the procedures that are touched by the selection. If the selection is within one procedure, I want what’s selected.

This code uses the Microsoft Visual Basic Extensibility library.

To get this Select this

In the last line that begins with sOutput = I had to add some extraneous spaces to be able to post code that contains code tags, but they’re not really there in the code.

Other than that I’m merely doing string manipulation with my starting and ending lines and columns.

I think I need to add the inline = "true" argument when I’m on a single line. I think I’ll use and see how often I’m adding it

Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.