How to Parse RTF String

R

Robert Mileski

Hi,

I have a question.

I want to put a string through VBA in Word, which has a "RTF Syntax" in a
Word document, but parsed, that is formatted.

I'll give you an example:

Sub ParseRTF()
Dim txtStr as String

txtStr = "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0
MS Sans Serif;}}\viewkind4\uc1\pard\lang1031\b\f0\fs17 This is an example of
a String in RTF Format\par }"

End Sub


So, now I have a String with RTF. The problem is now, how can I put this
text in a Word Document, but it should be pasted already formated, not just
as a plain text.

One way of doing this, is putting the String in a .rtf File, and then using
this command: Selection.InsertFile FileName:="C:\TEST.rtf", Link:=True


But I don't want to use a file, because of the time doing a disk read. I
want to paste the formatted string in the document directly.


I want to do this, because I have an MS Access Database, where I store the
RTF Strings in Memo Fields. I want to read them from the database, and
formatted, put them in a document.


Every help will be much appreciated.


Best Regards,
Robert Mileski
 
D

Dave

maybe paste it into an rtf control, then select and copy it back out, then
paste into word? not sure if the trip through the rtf control would convert
the formatting to something that word would like or not.

another possibility is to try the clipboard api and see if copying it to the
clipboard and pasting into word ffrom there converts it properly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top