web development India freelance website designer
Transfer formatted Rich Textbox text into Microsoft Word

As you know, VB's Rich Textbox control is no ordinary textbox. With it,
users not only can enter multiline text; but also apply RTF formatting,
such as bold, italics and color. Often, you may want to transfer this
formatted text into Microsoft Word. Fortunately, Visual Basic offers
several fairly simple ways to do so.

One way consists of copying the formatted text into the Clipboard
object, using Automation to open the Word Application, and then
pasting the formatted code into a blank document. The following
procedure shows how to accomplish this (it assumes you've set a
reference to the Microsoft Word 8.0/9.0 Object library).

Dim wrdApp As Word.Application

Private Sub Form_Load()
Set wrdApp = New Word.Application
End Sub

Private Sub Command2_Click()
Clipboard.SetText RichTextBox1.TextRTF, vbCFRTF
With wrdApp
.Documents.Add
.Selection.Paste
.ActiveDocument.SaveAs App.Path & "\RTFDOC2.doc", _
wdFormatDocument
.Visible = True
.Activate
End With
End Sub

As you can see, this code uses Visual Basic's Clipboard object to
accomplish the transfer. First, it uses the SetText() method to
capture the text. Then, it adds a new blank document to the Word
application's Documents collection. At this point, the cursor, or
Selection, is positioned at the top of the document, so all the code
need do is execute the Paste command to paste the Clipboard contents
into the document. Our code then saves the new document and displays it.
Transfer formatted Rich Textbox text into Microsof

1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700

Freelance ASP PHP web development | Web developer India Web development India| Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design