VBA to HTML – test

The formatting of VBA code fragements in a blog like this is an issue. Currently, I’m just putting the code within a <pre> block. Obviously, there’s no colour coding (and the line length’s rather limited). Anyway, I’ve come across a converter from Mr. Excel. It’s intended for Excel VBA code, so it’s installed as an Excel add-in.

Here’s a sample:

Sub GetFilenames()
        ‘pre: exists Worksheets(“list”)
        ‘pre: defined Range “filenames” = $A:$A
        ‘pre: defined Ranges “prefix”, “suffix”
        ‘post: Range “filenames” contains * matching file names

    Dim prefix As String
    Dim suffix As String
    Dim filename As String
    Dim rownum As Integer
    ChDir (ActiveWorkbook.Path)
    prefix = Range(“prefix”).Value
    suffix = Range(“suffix”).Value
    rownum = 1
    filename = Dir(prefix + “*” + suffix)
    Do While filename “”
        Range(“A” & rownum).Value = filename
        rownum = rownum + 1
        filename = Dir
End Sub

Let’s see what that looks like…

Hmmm… looks like it’s turned the double quotes into ‘smart’ quotes (&#8220;&#8221;), which are displayed strangely. Also, it hasn’t escaped the angle brackets in ‘<>’ (not equals). Disappointing.

The add-in provides extra menu options inside the VBA Editor, but there don’t seem to be any Options to set.


1 Response to “VBA to HTML – test”

  1. 1 geoffness March 28, 2009 at 10:30 am

    I use tags. You get one-click copy to clipboard, view plain popup and print options, and I think pretty close approximation to the view in the VBE. I like the look on the page of what that converter does but as you say disappointing that it doesn’t cope with quotes and escaping special characters.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

March 2009
« Feb   Apr »

%d bloggers like this: