Program for color printing VB sources

I am looking for a program with which you can print vb sources on a color printer with all the reserved words in their color, with the comments in green and so on.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Put all your code in the RTF file and
Use this code to print a RTF file (with colors)

' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         :
' * E-Mail           :
' * Date             : 30/07/99
' * Time             : 14:07
' **********************************************************************
' * Comments         : Print RTF
' *
' *
' **********************************************************************

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal msg As Long, ByVal wp As Long, lp As Any) As Long

Public Const WM_USER = &H400
Public Const EM_FORMATRANGE As Long = WM_USER + 57

Public Sub PrintRTF(rtf As RichTextBox, nnLeftMarginWidth As Long, nnTopMarginHeight As Long, nnRightMarginWidth As Long, nnBottomMarginHeight As Long)
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         :
   ' * E-Mail           :
   ' * Date             : 30/10/98
   ' * Time             : 14:43
   ' * Module Name      : Main_Module
   ' * Module Filename  : Main.bas
   ' * Procedure Name   : PrintRTF
   ' * Parameters       :
   ' *                    rtf As RichTextBox
   ' *                    nnLeftMarginWidth As Long
   ' *                    nnTopMarginHeight As Long
   ' *                    nnRightMarginWidth As Long
   ' *                    nnBottomMarginHeight As Long
   ' **********************************************************************
   ' * Comments         : Print RTF
   ' *
   ' *
   ' **********************************************************************
   Dim nLeftOffset      As Long
   Dim nTopOffset       As Long
   Dim nLeftMargin      As Long
   Dim nTopMargin       As Long
   Dim nRightMargin     As Long
   Dim nBottomMargin    As Long
   Dim fr               As FormatRange
   Dim rcDrawTo         As RECT
   Dim rcPage           As RECT
   Dim nTextLength      As Long
   Dim nNextCharPos     As Long
   Dim nRet             As Long
   Printer.Print Space(1)
   Printer.ScaleMode = vbTwips
   nLeftOffset = Printer.ScaleX(GetDeviceCaps(Printer.hdc, PHYSICALOFFSETX), vbPixels, vbTwips)
   nTopOffset = Printer.ScaleY(GetDeviceCaps(Printer.hdc, PHYSICALOFFSETY), vbPixels, vbTwips)
   nLeftMargin = nnLeftMarginWidth - nLeftOffset
   nTopMargin = nnTopMarginHeight - nTopOffset
   nRightMargin = (Printer.Width - nnRightMarginWidth) - nLeftOffset
   nBottomMargin = (Printer.Height - nnBottomMarginHeight) - nTopOffset
   rcPage.left = 0
   rcPage.tOp = 0
   rcPage.Right = Printer.ScaleWidth
   rcPage.Bottom = Printer.ScaleHeight
   rcDrawTo.left = nLeftMargin
   rcDrawTo.tOp = nTopMargin
   rcDrawTo.Right = nRightMargin
   rcDrawTo.Bottom = nBottomMargin
   fr.hdc = Printer.hdc
   fr.hdcTarget = Printer.hdc
   fr.rc = rcDrawTo
   fr.rcPage = rcPage
   fr.chrg.cpMin = 0
   fr.chrg.cpMax = -1
   nTextLength = Len(rtf.Text)
      fr.hdc = Printer.hdc
      fr.hdcTarget = Printer.hdc
      nNextCharPos = SendMessage(rtf.hwnd, EM_FORMATRANGE, True, fr)
      If nNextCharPos >= nTextLength Then Exit Do
      fr.chrg.cpMin = nNextCharPos
      Printer.Print Space(1)
   nRet = SendMessage(rtf.hwnd, EM_FORMATRANGE, False, ByVal CLng(0))

End Sub


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tsjarlieAuthor Commented:
Thank you for the fast answer,
the problem is that I am rather new to vb and don't exactly understand your solution, could you explain some more ?
I saved the vb source in word in a rtf format, the I made a new project in vb6
and cut and paste your source in a form but when I ran the program I got an error on the constant declaration.
What am I doing wrong ? Everything ?

Could you tell me on wich line?
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

tsjarlieAuthor Commented:
the line is :

Public Const WM_USER = &H400

the error is :

Compile error:

Constants, fixed-lenght strings, arrays, user-defined types and Declare statements not allowed as Public members of object modules
Remove the "Public" word from the line or move the code to a .bas module.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.