Hello,

What will be the equivalent VBA code for the following VB code?? (The
code prints RichTextBox control).


Private Sub cmdDirPrint_Click()

ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums

If rtbPropDirections.SelLength = 0 Then
ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDAllPages
Else
ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDSelection
End If


ComDiaPropPrint.ShowPrinter
printer.Print ""
rtbPropDirections.SelPrint printer.hDC
printer.enddoc


End Sub

Thanks
Kumar

Re: Convert this VB code to VBA by Jonathan

Jonathan
Thu Dec 11 09:45:20 CST 2003

It's not possible to convert this code directly because VBA doesn't support
the Printer object, and doesn't allow direct printing from VBA, only
printing of Word documents using the Printout methid.

What are you trying to achieve?

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup


"Kumar" <kamur@lycos.com> wrote in message
news:7517e3e1.0312091944.343802ae@posting.google.com...
> Hello,
>
> What will be the equivalent VBA code for the following VB code?? (The
> code prints RichTextBox control).
>
>
> Private Sub cmdDirPrint_Click()
>
> ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
>
> If rtbPropDirections.SelLength = 0 Then
> ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDAllPages
> Else
> ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDSelection
> End If
>
>
> ComDiaPropPrint.ShowPrinter
> printer.Print ""
> rtbPropDirections.SelPrint printer.hDC
> printer.enddoc
>
>
> End Sub
>
> Thanks
> Kumar


Re: Convert this VB code to VBA by kamur

kamur
Thu Dec 11 19:32:08 CST 2003

My macros in Word produce a report which is displayed on a userform
Richtextbox control. I needed to print the report to the default
printer. I came across this vb code that does the printing, but didn't
know its vba equivalent.

Alternatively, I tried producing the report in a txt file and then
using shell command to print it. It prints, but it doesnot have the
beauty of a print from a richtext box. Like, How can I control fonts
and their formatting in notepad and more importantly, when the line is
too long, the print chops off the right end of the lines. Notepad
printout does not come good at all, unless there is a way that I can
make it look like richtextbox printout from vb.

Any other suggestions also welcome !!!

Thanks
Kumar





"Jonathan West" <jwest@mvps.org> wrote in message news:<OiLoh5$vDHA.2484@TK2MSFTNGP09.phx.gbl>...
> It's not possible to convert this code directly because VBA doesn't support
> the Printer object, and doesn't allow direct printing from VBA, only
> printing of Word documents using the Printout methid.
>
> What are you trying to achieve?
>
> --
> Regards
> Jonathan West - Word MVP
> http://www.multilinker.com
> Please reply to the newsgroup
>
>
> "Kumar" <kamur@lycos.com> wrote in message
> news:7517e3e1.0312091944.343802ae@posting.google.com...
> > Hello,
> >
> > What will be the equivalent VBA code for the following VB code?? (The
> > code prints RichTextBox control).
> >
> >
> > Private Sub cmdDirPrint_Click()
> >
> > ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
> >
> > If rtbPropDirections.SelLength = 0 Then
> > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDAllPages
> > Else
> > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDSelection
> > End If
> >
> >
> > ComDiaPropPrint.ShowPrinter
> > printer.Print ""
> > rtbPropDirections.SelPrint printer.hDC
> > printer.enddoc
> >
> >
> > End Sub
> >
> > Thanks
> > Kumar

Re: Convert this VB code to VBA by JGM

JGM
Thu Dec 11 21:04:18 CST 2003

Hi Kumar,

Why don't you send the formatted report back to a "temporary" Word document
and print it from there?

For example:
'_______________________________________
Private Sub CommandButton1_Click()

'This codes assumes you already have a blank Word document open

Dim CurrentPara As Paragraph
Dim myRTFdoc As Document

Const RTFDocPathandName As String = _
"D:\Test\myrtf.rtf"

Set CurrentPara = Selection.Paragraphs(1)

RichTextBox1.SaveFile RTFDocPathandName

Set myRTFdoc = Documents.Open(FileName:=RTFDocPathandName,
Visible:=False)

CurrentPara.Range.FormattedText = myRTFdoc.Content.FormattedText

myRTFdoc.Close

'do the printing here

Set CurrentPara = Nothing
Set myRTFdoc = Nothing

End Sub
'_______________________________________

HTH
Cheers!

--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca

"Kumar" <kamur@lycos.com> a écrit dans le message de news:
7517e3e1.0312111732.21fca1f1@posting.google.com...
> My macros in Word produce a report which is displayed on a userform
> Richtextbox control. I needed to print the report to the default
> printer. I came across this vb code that does the printing, but didn't
> know its vba equivalent.
>
> Alternatively, I tried producing the report in a txt file and then
> using shell command to print it. It prints, but it doesnot have the
> beauty of a print from a richtext box. Like, How can I control fonts
> and their formatting in notepad and more importantly, when the line is
> too long, the print chops off the right end of the lines. Notepad
> printout does not come good at all, unless there is a way that I can
> make it look like richtextbox printout from vb.
>
> Any other suggestions also welcome !!!
>
> Thanks
> Kumar
>
>
>
>
>
> "Jonathan West" <jwest@mvps.org> wrote in message
news:<OiLoh5$vDHA.2484@TK2MSFTNGP09.phx.gbl>...
> > It's not possible to convert this code directly because VBA doesn't
support
> > the Printer object, and doesn't allow direct printing from VBA, only
> > printing of Word documents using the Printout methid.
> >
> > What are you trying to achieve?
> >
> > --
> > Regards
> > Jonathan West - Word MVP
> > http://www.multilinker.com
> > Please reply to the newsgroup
> >
> >
> > "Kumar" <kamur@lycos.com> wrote in message
> > news:7517e3e1.0312091944.343802ae@posting.google.com...
> > > Hello,
> > >
> > > What will be the equivalent VBA code for the following VB code?? (The
> > > code prints RichTextBox control).
> > >
> > >
> > > Private Sub cmdDirPrint_Click()
> > >
> > > ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
> > >
> > > If rtbPropDirections.SelLength = 0 Then
> > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDAllPages
> > > Else
> > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDSelection
> > > End If
> > >
> > >
> > > ComDiaPropPrint.ShowPrinter
> > > printer.Print ""
> > > rtbPropDirections.SelPrint printer.hDC
> > > printer.enddoc
> > >
> > >
> > > End Sub
> > >
> > > Thanks
> > > Kumar



Re: Convert this VB code to VBA by anonymous

anonymous
Fri Dec 12 11:12:17 CST 2003

Output the data as HTML. You can then host the Microsoft
Web Broswer Control (shdocvw.dll) on your VBA form. You
can then load the HTML into that contol.

Mark Baird

>-----Original Message-----
>My macros in Word produce a report which is displayed on
a userform
>Richtextbox control. I needed to print the report to the
default
>printer. I came across this vb code that does the
printing, but didn't
>know its vba equivalent.
>
>Alternatively, I tried producing the report in a txt file
and then
>using shell command to print it. It prints, but it
doesnot have the
>beauty of a print from a richtext box. Like, How can I
control fonts
>and their formatting in notepad and more importantly,
when the line is
>too long, the print chops off the right end of the lines.
Notepad
>printout does not come good at all, unless there is a way
that I can
>make it look like richtextbox printout from vb.
>
>Any other suggestions also welcome !!!
>
>Thanks
>Kumar
>
>
>
>
>
>"Jonathan West" <jwest@mvps.org> wrote in message
news:<OiLoh5$vDHA.2484@TK2MSFTNGP09.phx.gbl>...
>> It's not possible to convert this code directly because
VBA doesn't support
>> the Printer object, and doesn't allow direct printing
from VBA, only
>> printing of Word documents using the Printout methid.
>>
>> What are you trying to achieve?
>>
>> --
>> Regards
>> Jonathan West - Word MVP
>> http://www.multilinker.com
>> Please reply to the newsgroup
>>
>>
>> "Kumar" <kamur@lycos.com> wrote in message
>> news:7517e3e1.0312091944.343802ae@posting.google.com...
>> > Hello,
>> >
>> > What will be the equivalent VBA code for the
following VB code?? (The
>> > code prints RichTextBox control).
>> >
>> >
>> > Private Sub cmdDirPrint_Click()
>> >
>> > ComDiaPropPrint.Flags = cdlPDReturnDC +
cdlPDNoPageNums
>> >
>> > If rtbPropDirections.SelLength = 0 Then
>> > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags
+ cdlPDAllPages
>> > Else
>> > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags
+ cdlPDSelection
>> > End If
>> >
>> >
>> > ComDiaPropPrint.ShowPrinter
>> > printer.Print ""
>> > rtbPropDirections.SelPrint printer.hDC
>> > printer.enddoc
>> >
>> >
>> > End Sub
>> >
>> > Thanks
>> > Kumar
>.
>

Re: Convert this VB code to VBA by kamur

kamur
Fri Dec 12 18:15:44 CST 2003

Thanks JGM,

One question, maybe I am confused. But how do I do the printing here?
What will be code for printing?

Thanks
Kamur

"JGM" <no-spam@leaveme.alone> wrote in message news:<#sn#0uFwDHA.2080@TK2MSFTNGP10.phx.gbl>...
> Hi Kumar,
>
> Why don't you send the formatted report back to a "temporary" Word document
> and print it from there?
>
> For example:
> '_______________________________________
> Private Sub CommandButton1_Click()
>
> 'This codes assumes you already have a blank Word document open
>
> Dim CurrentPara As Paragraph
> Dim myRTFdoc As Document
>
> Const RTFDocPathandName As String = _
> "D:\Test\myrtf.rtf"
>
> Set CurrentPara = Selection.Paragraphs(1)
>
> RichTextBox1.SaveFile RTFDocPathandName
>
> Set myRTFdoc = Documents.Open(FileName:=RTFDocPathandName,
> Visible:=False)
>
> CurrentPara.Range.FormattedText = myRTFdoc.Content.FormattedText
>
> myRTFdoc.Close
>
> 'do the printing here
>
> Set CurrentPara = Nothing
> Set myRTFdoc = Nothing
>
> End Sub
> '_______________________________________
>
> HTH
> Cheers!
>
> --
> _______________________________________
> Jean-Guy Marcil
> jmarcil@sympatico.ca
>
> "Kumar" <kamur@lycos.com> a écrit dans le message de news:
> 7517e3e1.0312111732.21fca1f1@posting.google.com...
> > My macros in Word produce a report which is displayed on a userform
> > Richtextbox control. I needed to print the report to the default
> > printer. I came across this vb code that does the printing, but didn't
> > know its vba equivalent.
> >
> > Alternatively, I tried producing the report in a txt file and then
> > using shell command to print it. It prints, but it doesnot have the
> > beauty of a print from a richtext box. Like, How can I control fonts
> > and their formatting in notepad and more importantly, when the line is
> > too long, the print chops off the right end of the lines. Notepad
> > printout does not come good at all, unless there is a way that I can
> > make it look like richtextbox printout from vb.
> >
> > Any other suggestions also welcome !!!
> >
> > Thanks
> > Kumar
> >
> >
> >
> >
> >
> > "Jonathan West" <jwest@mvps.org> wrote in message
> news:<OiLoh5$vDHA.2484@TK2MSFTNGP09.phx.gbl>...
> > > It's not possible to convert this code directly because VBA doesn't
> support
> > > the Printer object, and doesn't allow direct printing from VBA, only
> > > printing of Word documents using the Printout methid.
> > >
> > > What are you trying to achieve?
> > >
> > > --
> > > Regards
> > > Jonathan West - Word MVP
> > > http://www.multilinker.com
> > > Please reply to the newsgroup
> > >
> > >
> > > "Kumar" <kamur@lycos.com> wrote in message
> > > news:7517e3e1.0312091944.343802ae@posting.google.com...
> > > > Hello,
> > > >
> > > > What will be the equivalent VBA code for the following VB code?? (The
> > > > code prints RichTextBox control).
> > > >
> > > >
> > > > Private Sub cmdDirPrint_Click()
> > > >
> > > > ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
> > > >
> > > > If rtbPropDirections.SelLength = 0 Then
> > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDAllPages
> > > > Else
> > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags + cdlPDSelection
> > > > End If
> > > >
> > > >
> > > > ComDiaPropPrint.ShowPrinter
> > > > printer.Print ""
> > > > rtbPropDirections.SelPrint printer.hDC
> > > > printer.enddoc
> > > >
> > > >
> > > > End Sub
> > > >
> > > > Thanks
> > > > Kumar

Re: Convert this VB code to VBA by JGM

JGM
Fri Dec 12 19:42:55 CST 2003

Hi Kumar,

Look up the PrintOut method in the Word VBA Help, there are lots of examples
and they explain it way better that I can!

Good luck!

--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca

"Kumar" <kamur@lycos.com> a écrit dans le message de news:
7517e3e1.0312121615.686f034f@posting.google.com...
> Thanks JGM,
>
> One question, maybe I am confused. But how do I do the printing here?
> What will be code for printing?
>
> Thanks
> Kamur
>
> "JGM" <no-spam@leaveme.alone> wrote in message
news:<#sn#0uFwDHA.2080@TK2MSFTNGP10.phx.gbl>...
> > Hi Kumar,
> >
> > Why don't you send the formatted report back to a "temporary" Word
document
> > and print it from there?
> >
> > For example:
> > '_______________________________________
> > Private Sub CommandButton1_Click()
> >
> > 'This codes assumes you already have a blank Word document open
> >
> > Dim CurrentPara As Paragraph
> > Dim myRTFdoc As Document
> >
> > Const RTFDocPathandName As String = _
> > "D:\Test\myrtf.rtf"
> >
> > Set CurrentPara = Selection.Paragraphs(1)
> >
> > RichTextBox1.SaveFile RTFDocPathandName
> >
> > Set myRTFdoc = Documents.Open(FileName:=RTFDocPathandName,
> > Visible:=False)
> >
> > CurrentPara.Range.FormattedText = myRTFdoc.Content.FormattedText
> >
> > myRTFdoc.Close
> >
> > 'do the printing here
> >
> > Set CurrentPara = Nothing
> > Set myRTFdoc = Nothing
> >
> > End Sub
> > '_______________________________________
> >
> > HTH
> > Cheers!
> >
> > --
> > _______________________________________
> > Jean-Guy Marcil
> > jmarcil@sympatico.ca
> >
> > "Kumar" <kamur@lycos.com> a écrit dans le message de news:
> > 7517e3e1.0312111732.21fca1f1@posting.google.com...
> > > My macros in Word produce a report which is displayed on a userform
> > > Richtextbox control. I needed to print the report to the default
> > > printer. I came across this vb code that does the printing, but didn't
> > > know its vba equivalent.
> > >
> > > Alternatively, I tried producing the report in a txt file and then
> > > using shell command to print it. It prints, but it doesnot have the
> > > beauty of a print from a richtext box. Like, How can I control fonts
> > > and their formatting in notepad and more importantly, when the line is
> > > too long, the print chops off the right end of the lines. Notepad
> > > printout does not come good at all, unless there is a way that I can
> > > make it look like richtextbox printout from vb.
> > >
> > > Any other suggestions also welcome !!!
> > >
> > > Thanks
> > > Kumar
> > >
> > >
> > >
> > >
> > >
> > > "Jonathan West" <jwest@mvps.org> wrote in message
> > news:<OiLoh5$vDHA.2484@TK2MSFTNGP09.phx.gbl>...
> > > > It's not possible to convert this code directly because VBA doesn't
> > support
> > > > the Printer object, and doesn't allow direct printing from VBA, only
> > > > printing of Word documents using the Printout methid.
> > > >
> > > > What are you trying to achieve?
> > > >
> > > > --
> > > > Regards
> > > > Jonathan West - Word MVP
> > > > http://www.multilinker.com
> > > > Please reply to the newsgroup
> > > >
> > > >
> > > > "Kumar" <kamur@lycos.com> wrote in message
> > > > news:7517e3e1.0312091944.343802ae@posting.google.com...
> > > > > Hello,
> > > > >
> > > > > What will be the equivalent VBA code for the following VB code??
(The
> > > > > code prints RichTextBox control).
> > > > >
> > > > >
> > > > > Private Sub cmdDirPrint_Click()
> > > > >
> > > > > ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
> > > > >
> > > > > If rtbPropDirections.SelLength = 0 Then
> > > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags +
cdlPDAllPages
> > > > > Else
> > > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags +
cdlPDSelection
> > > > > End If
> > > > >
> > > > >
> > > > > ComDiaPropPrint.ShowPrinter
> > > > > printer.Print ""
> > > > > rtbPropDirections.SelPrint printer.hDC
> > > > > printer.enddoc
> > > > >
> > > > >
> > > > > End Sub
> > > > >
> > > > > Thanks
> > > > > Kumar



Re: Convert this VB code to VBA by Kamur

Kamur
Sat Dec 13 00:04:12 CST 2003

Thanks JGM. I did look at the printout method....I will be trying it out
tomorrow.

Kamur

"JGM" <no-spam@leaveme.alone> wrote in message
news:OTNpKmRwDHA.2460@TK2MSFTNGP10.phx.gbl...
> Hi Kumar,
>
> Look up the PrintOut method in the Word VBA Help, there are lots of
examples
> and they explain it way better that I can!
>
> Good luck!
>
> --
> _______________________________________
> Jean-Guy Marcil
> jmarcil@sympatico.ca
>
> "Kumar" <kamur@lycos.com> a écrit dans le message de news:
> 7517e3e1.0312121615.686f034f@posting.google.com...
> > Thanks JGM,
> >
> > One question, maybe I am confused. But how do I do the printing here?
> > What will be code for printing?
> >
> > Thanks
> > Kamur
> >
> > "JGM" <no-spam@leaveme.alone> wrote in message
> news:<#sn#0uFwDHA.2080@TK2MSFTNGP10.phx.gbl>...
> > > Hi Kumar,
> > >
> > > Why don't you send the formatted report back to a "temporary" Word
> document
> > > and print it from there?
> > >
> > > For example:
> > > '_______________________________________
> > > Private Sub CommandButton1_Click()
> > >
> > > 'This codes assumes you already have a blank Word document open
> > >
> > > Dim CurrentPara As Paragraph
> > > Dim myRTFdoc As Document
> > >
> > > Const RTFDocPathandName As String = _
> > > "D:\Test\myrtf.rtf"
> > >
> > > Set CurrentPara = Selection.Paragraphs(1)
> > >
> > > RichTextBox1.SaveFile RTFDocPathandName
> > >
> > > Set myRTFdoc = Documents.Open(FileName:=RTFDocPathandName,
> > > Visible:=False)
> > >
> > > CurrentPara.Range.FormattedText = myRTFdoc.Content.FormattedText
> > >
> > > myRTFdoc.Close
> > >
> > > 'do the printing here
> > >
> > > Set CurrentPara = Nothing
> > > Set myRTFdoc = Nothing
> > >
> > > End Sub
> > > '_______________________________________
> > >
> > > HTH
> > > Cheers!
> > >
> > > --
> > > _______________________________________
> > > Jean-Guy Marcil
> > > jmarcil@sympatico.ca
> > >
> > > "Kumar" <kamur@lycos.com> a écrit dans le message de news:
> > > 7517e3e1.0312111732.21fca1f1@posting.google.com...
> > > > My macros in Word produce a report which is displayed on a userform
> > > > Richtextbox control. I needed to print the report to the default
> > > > printer. I came across this vb code that does the printing, but
didn't
> > > > know its vba equivalent.
> > > >
> > > > Alternatively, I tried producing the report in a txt file and then
> > > > using shell command to print it. It prints, but it doesnot have the
> > > > beauty of a print from a richtext box. Like, How can I control fonts
> > > > and their formatting in notepad and more importantly, when the line
is
> > > > too long, the print chops off the right end of the lines. Notepad
> > > > printout does not come good at all, unless there is a way that I can
> > > > make it look like richtextbox printout from vb.
> > > >
> > > > Any other suggestions also welcome !!!
> > > >
> > > > Thanks
> > > > Kumar
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > "Jonathan West" <jwest@mvps.org> wrote in message
> > > news:<OiLoh5$vDHA.2484@TK2MSFTNGP09.phx.gbl>...
> > > > > It's not possible to convert this code directly because VBA
doesn't
> > > support
> > > > > the Printer object, and doesn't allow direct printing from VBA,
only
> > > > > printing of Word documents using the Printout methid.
> > > > >
> > > > > What are you trying to achieve?
> > > > >
> > > > > --
> > > > > Regards
> > > > > Jonathan West - Word MVP
> > > > > http://www.multilinker.com
> > > > > Please reply to the newsgroup
> > > > >
> > > > >
> > > > > "Kumar" <kamur@lycos.com> wrote in message
> > > > > news:7517e3e1.0312091944.343802ae@posting.google.com...
> > > > > > Hello,
> > > > > >
> > > > > > What will be the equivalent VBA code for the following VB code??
> (The
> > > > > > code prints RichTextBox control).
> > > > > >
> > > > > >
> > > > > > Private Sub cmdDirPrint_Click()
> > > > > >
> > > > > > ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
> > > > > >
> > > > > > If rtbPropDirections.SelLength = 0 Then
> > > > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags +
> cdlPDAllPages
> > > > > > Else
> > > > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags +
> cdlPDSelection
> > > > > > End If
> > > > > >
> > > > > >
> > > > > > ComDiaPropPrint.ShowPrinter
> > > > > > printer.Print ""
> > > > > > rtbPropDirections.SelPrint printer.hDC
> > > > > > printer.enddoc
> > > > > >
> > > > > >
> > > > > > End Sub
> > > > > >
> > > > > > Thanks
> > > > > > Kumar
>
>



Re: Convert this VB code to VBA by Jonathan

Jonathan
Fri Dec 12 18:57:14 CST 2003

To print out a document, you use the Printout method of the Document object.

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

"Kumar" <kamur@lycos.com> wrote in message
news:7517e3e1.0312121615.686f034f@posting.google.com...
> Thanks JGM,
>
> One question, maybe I am confused. But how do I do the printing here?
> What will be code for printing?
>
> Thanks
> Kamur
>
> "JGM" <no-spam@leaveme.alone> wrote in message
news:<#sn#0uFwDHA.2080@TK2MSFTNGP10.phx.gbl>...
> > Hi Kumar,
> >
> > Why don't you send the formatted report back to a "temporary" Word
document
> > and print it from there?
> >
> > For example:
> > '_______________________________________
> > Private Sub CommandButton1_Click()
> >
> > 'This codes assumes you already have a blank Word document open
> >
> > Dim CurrentPara As Paragraph
> > Dim myRTFdoc As Document
> >
> > Const RTFDocPathandName As String = _
> > "D:\Test\myrtf.rtf"
> >
> > Set CurrentPara = Selection.Paragraphs(1)
> >
> > RichTextBox1.SaveFile RTFDocPathandName
> >
> > Set myRTFdoc = Documents.Open(FileName:=RTFDocPathandName,
> > Visible:=False)
> >
> > CurrentPara.Range.FormattedText = myRTFdoc.Content.FormattedText
> >
> > myRTFdoc.Close
> >
> > 'do the printing here
> >
> > Set CurrentPara = Nothing
> > Set myRTFdoc = Nothing
> >
> > End Sub
> > '_______________________________________
> >
> > HTH
> > Cheers!
> >
> > --
> > _______________________________________
> > Jean-Guy Marcil
> > jmarcil@sympatico.ca
> >
> > "Kumar" <kamur@lycos.com> a écrit dans le message de news:
> > 7517e3e1.0312111732.21fca1f1@posting.google.com...
> > > My macros in Word produce a report which is displayed on a userform
> > > Richtextbox control. I needed to print the report to the default
> > > printer. I came across this vb code that does the printing, but didn't
> > > know its vba equivalent.
> > >
> > > Alternatively, I tried producing the report in a txt file and then
> > > using shell command to print it. It prints, but it doesnot have the
> > > beauty of a print from a richtext box. Like, How can I control fonts
> > > and their formatting in notepad and more importantly, when the line is
> > > too long, the print chops off the right end of the lines. Notepad
> > > printout does not come good at all, unless there is a way that I can
> > > make it look like richtextbox printout from vb.
> > >
> > > Any other suggestions also welcome !!!
> > >
> > > Thanks
> > > Kumar
> > >
> > >
> > >
> > >
> > >
> > > "Jonathan West" <jwest@mvps.org> wrote in message
> > news:<OiLoh5$vDHA.2484@TK2MSFTNGP09.phx.gbl>...
> > > > It's not possible to convert this code directly because VBA doesn't
> > support
> > > > the Printer object, and doesn't allow direct printing from VBA, only
> > > > printing of Word documents using the Printout methid.
> > > >
> > > > What are you trying to achieve?
> > > >
> > > > --
> > > > Regards
> > > > Jonathan West - Word MVP
> > > > http://www.multilinker.com
> > > > Please reply to the newsgroup
> > > >
> > > >
> > > > "Kumar" <kamur@lycos.com> wrote in message
> > > > news:7517e3e1.0312091944.343802ae@posting.google.com...
> > > > > Hello,
> > > > >
> > > > > What will be the equivalent VBA code for the following VB code??
(The
> > > > > code prints RichTextBox control).
> > > > >
> > > > >
> > > > > Private Sub cmdDirPrint_Click()
> > > > >
> > > > > ComDiaPropPrint.Flags = cdlPDReturnDC + cdlPDNoPageNums
> > > > >
> > > > > If rtbPropDirections.SelLength = 0 Then
> > > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags +
cdlPDAllPages
> > > > > Else
> > > > > ComDiaPropPrint.Flags = ComDiaPropPrint.Flags +
cdlPDSelection
> > > > > End If
> > > > >
> > > > >
> > > > > ComDiaPropPrint.ShowPrinter
> > > > > printer.Print ""
> > > > > rtbPropDirections.SelPrint printer.hDC
> > > > > printer.enddoc
> > > > >
> > > > >
> > > > > End Sub
> > > > >
> > > > > Thanks
> > > > > Kumar