Export VBA code to Word but keep color format

Rick85

New Member
Joined
Apr 7, 2010
Messages
11
Hi guys!

I was wondering how can i export VBA code to a text editor like word, keeping the color formats.

Does anyone know?

Thanks in advance
Rick
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Are you trying to this so that you can print it?
If you mean that the reserved words, comments etc. need to be colored then you will not be able to that (or if so, it is something that I have not come across).
I use two software products when I want to do this - either (a) EditPad Pro or (b) VBA Code Print.
EditPad Pro (impressive text editor):
http://www.just-great-software.com/
VBA Code Print (print utility):
http://www.ozgrid.com/Services/print-vba-code.htm
 
Upvote 0
I know this is old, but the question remain.

I have to write technical documentation for the company I work and develop for and it has to be in Word 2010.

I do use Notepad++ extensively for other things, but my document must end up in Word.

So the question remains:

How can I copy VBA code from the VB Editor in either MS Excel or MS Access into a Word document and keep its full formatting (font and coloring)?

Thank you for helping.
 
Upvote 0
I found the perfect solution to this question from another forum:
How do you display code snippets in MS Word preserving format and syntax highlighting? - Stack Overflow

Keep in mind that the font pasted into Word will be the font on the Notepad++ document.

If another font is required (smaller for example), you have to change it first in Notepad++/Settings/Style Configurator and make sure it is applied. I had to check the "Global xxx" boxes.

Really nice! Very easy.

Still, one would think that Microsoft would have thought about this type of request and needs. A special "Style" built-in that would automatically reproduce the VBA font/color would have been really good and surely a piece of cake to develop and implement in a MS developer genius brain!
 
Upvote 0
I have to write technical documentation for the company I work and develop for and it has to be in Word 2010.

I do use Notepad++ extensively for other things, but my document must end up in Word.

So the question remains:

How can I copy VBA code from the VB Editor in either MS Excel or MS Access into a Word document and keep its full formatting (font and coloring)?

3+ years later, but here's my approach. The dinosaur in me sometimes still likes to work with pencil and ink on code printouts.

Copy the VBA, paste into a new file in Notepad++ aka NPP.

Change the language to VB (Alt-L for Language menu > V).

Use the NppExport plugin (part of the standard NPP install) to copy the RTF to the clipboard. Alt-P for Plugins menu, then arrow up or down to select NppExport, right arrow to choices, up or down arrow to Copy RTF to Clipboard.

Switch to Word, open a new file (I've made my own Word template that's got some formatting plus a small Word VBA procedure that selects everything and applies the font and size I want, Consolas 8pt), and paste.

I'd like to automate the NPP piece, but as it is, it takes just a few seconds per module, less time than it takes to retrieve the printout from the printer.
 
Upvote 0

Forum statistics

Threads
1,223,675
Messages
6,173,748
Members
452,533
Latest member
Alex19k

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top