text2vbastring

About Project

This program is a GUI where you can paste/type text into an editor, and get a valid VBA string literal as output.

Motivation

I made an Excel macro to fetch rows from a database. I just wanted to hardcode the query to save some time. But, the SQL statement was about 80 lines long, and I found out that Visual Basic has a few limitations that impact string literals.

  1. Line length is limited to 1023 characters. This means that I can't just put a huge query on one line.
  2. Each statement can only have 25 line continuation characters. This means that I can't do something like this:
                myStr = "line 1" & _
                "line 2" & _
                ...
                "line 100"
                
    Instead, the statement has to be broken up:
                myStr = "line 1" & _
                "line 2" & _
                ...
                "line 25"
                myStr = myStr & "line 26" & _
                ...
                "line 100"
                

The text2vbastring tool handles both of these limitations automatically: all you need to do is paste and/or type text into the text box, then copy and paste the output directly into the Excel VBA editor!

application demonstration
Pasting a string into the text box.

More info:

Download

SHA256 sum: c60c106560a7af69021a25bd8c799a7e30b67d0ed561cf3649209c8a4e269002