Export VBA code to Word but keep color format
Results 1 to 7 of 7

Thread: Export VBA code to Word but keep color format
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Apr 2010
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Export VBA code to Word but keep color format

    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

  2. #2
    Board Regular
    Join Date
    Dec 2005
    Location
    Basingstoke (UK)
    Posts
    2,390
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Export VBA code to Word but keep color format

    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
    Never give way to anger - otherwise in one day you could burn up the wood that you collected in many bitter weeks.

  3. #3
    New Member
    Join Date
    Dec 2012
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Export VBA code to Word but keep color format

    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.

  4. #4
    New Member
    Join Date
    Dec 2012
    Posts
    13
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Export VBA code to Word but keep color format

    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!

  5. #5
    New Member
    Join Date
    Sep 2014
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Export VBA code to Word but keep color format

    Quote Originally Posted by Rick85 View Post
    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

    Try the VBA script from Chris Macro:

    Format VBA Code Inside A Microsoft Word Document

  6. #6
    MrExcel MVP
    Join Date
    May 2003
    Location
    USA
    Posts
    4,635
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Export VBA code to Word but keep color format

    Quote Originally Posted by marcnz View Post
    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.
    Jon Peltier
    Peltier Technical Services, Inc.
    Try Peltier Tech Charts for Excel

  7. #7
    Board Regular
    Join Date
    Feb 2011
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Export VBA code to Word but keep color format

    Thank you. That info worked perfectly for me.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •