• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

Saving VB form code to Word format , retaining colours

I need to save my VB code from a form to Word 98 format for some documentation. I need to retain the blue and green colouring used by VB. As VB adds the colours itself, I can't just copy it to the clipboard, as it turns out all black. Any ideas?
1 Solution
Unless you do a "screen capture" you're going to have to color the text yourself...

Hitching a ride...

I don't know the solution, but I can make a suggestion, perhaps..

The way I would approach this is to use the object interface to word. Then I would open the VB document as a text document.

You could then read in the VB file line by line.

You'll need to find the first single quote ' outside a pair of double quotes. That'll be the beginning of a comment.

Make sure you process the line continuation characters _

Now you can accurately colour lines or parts of lines green (comments)

The blue colour is going to be a lot more difficult. You may have to make a list of VB reserved keywords etc to achieve this with any degree of accuracy.

All in all, I do not think this is going to be an easy task.
Source Code Printing Demo Program

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now