Discussion:
Inserting a Rich Text Formatted string into a Word Document object
(too old to reply)
Jon in Canby Or.
2004-10-31 19:09:05 UTC
Permalink
I have stored a string in a SQL Server field that is the formatted text from
a VB6 RichTextBox object. I would now like to insert that string into a Word
Document Object while keeping the formatting from the database string. I am
doing this from VB6 using the Microsoft Word 10.0 Object Library. Any clues
on how to approach this?

Cheers,
Jon
Doug Robbins
2004-11-01 02:08:05 UTC
Permalink
Use the .FormattedText property of the Range or Selection object.
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
Post by Jon in Canby Or.
I have stored a string in a SQL Server field that is the formatted text from
a VB6 RichTextBox object. I would now like to insert that string into a Word
Document Object while keeping the formatting from the database string. I am
doing this from VB6 using the Microsoft Word 10.0 Object Library. Any clues
on how to approach this?
Cheers,
Jon
Jon in Canby Or.
2004-11-01 15:55:01 UTC
Permalink
I looked at the FormattedText property but didn't see how I would use this.
The help pages are not all that detailed. They show how to copy a Word
formatted paragraph from a Word document and insert it into another area of a
Word document. But there is no discussion on how to get an RTF formatting
information into the range object in the first place.
Post by Doug Robbins
Use the .FormattedText property of the Range or Selection object.
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
Post by Jon in Canby Or.
I have stored a string in a SQL Server field that is the formatted text from
a VB6 RichTextBox object. I would now like to insert that string into a Word
Document Object while keeping the formatting from the database string. I am
doing this from VB6 using the Microsoft Word 10.0 Object Library. Any clues
on how to approach this?
Cheers,
Jon
Jonathan West
2004-11-01 16:33:18 UTC
Permalink
Post by Jon in Canby Or.
I looked at the FormattedText property but didn't see how I would use this.
The help pages are not all that detailed. They show how to copy a Word
formatted paragraph from a Word document and insert it into another area of a
Word document. But there is no discussion on how to get an RTF formatting
information into the range object in the first place.
You're quite right. The FormattedText property can only be used for moving
formatted text between Word documents at least between documents that can be
opened in Word.

If you want to insert RTF formatted text from any other source, the only two
method I know of are as follows

1. Place the formatted text on the clipboard and paste it in.
2. Place the fomatted text into an RTF or HTML file, and insert the file.

I suspect the first of these options is going to be more practical for you.
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Jon in Canby Or.
2004-11-01 21:05:02 UTC
Permalink
Thanks. Just for the record I found the following code works well:
Set wRng = wDoc.Paragraphs(wDoc.Paragraphs.Count).Range
Clipboard.Clear
Clipboard.SetText strRTFToInsert, vbCFRTF
wRng.Paste
Post by Jonathan West
Post by Jon in Canby Or.
I looked at the FormattedText property but didn't see how I would use this.
The help pages are not all that detailed. They show how to copy a Word
formatted paragraph from a Word document and insert it into another area of a
Word document. But there is no discussion on how to get an RTF formatting
information into the range object in the first place.
You're quite right. The FormattedText property can only be used for moving
formatted text between Word documents at least between documents that can be
opened in Word.
If you want to insert RTF formatted text from any other source, the only two
method I know of are as follows
1. Place the formatted text on the clipboard and paste it in.
2. Place the fomatted text into an RTF or HTML file, and insert the file.
I suspect the first of these options is going to be more practical for you.
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
John H
2005-01-11 21:52:09 UTC
Permalink
I think you can do:

1) Save the formatted string in a temp RTF file and then
insert the file into your Word document,
or
2) Copy the formatted string into the Clipboard and then
Paste it into your Word document (I am not sure how to
copy to the Clipboard).

John
-----Original Message-----
I have stored a string in a SQL Server field that is the
formatted text from
a VB6 RichTextBox object. I would now like to insert
that string into a Word
Document Object while keeping the formatting from the
database string. I am
doing this from VB6 using the Microsoft Word 10.0 Object
Library. Any clues
on how to approach this?
Cheers,
Jon
.
Loading...