Re: Hot to parse RTF String



Hi Robert:

1) Define styles in the Word document template containing the formatting
you require.

2) Store in the database two columns, one containing the style name, the
other containing the string.

3) Use VBA in Word to retrieve the strings from the database. It can
automatically apply the associated style to each string as it brings it in.

Cheers

On 14/1/07 4:55 AM, in article #LcPsvzNHHA.4604@xxxxxxxxxxxxxxxxxxxx,
"Robert Mileski" <r_mileski@xxxxxxxxxxx> wrote:

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



--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <john@xxxxxxxxxxx>
Microsoft MVP, Word and Word for Macintosh. Business Analyst, Consultant
Technical Writer.
Sydney, Australia +61 (0) 4 1209 1410

.



Relevant Pages

  • Re: WORD Mailmerge with Excel DataSource - loss of formatting
    ... placing the field back into the database in all caps. ... functioning but I also need to simply open a word document from within excel ... the formatting, and using DDE to connect to try to solve that problem ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Parse irregular data, dump into delimited text file
    ... > I've been given an MS Word document containing information to input into ... > The vicarage, town place ... > into another database. ... # Remove the newline at the end of the string. ...
    (comp.unix.shell)
  • Encoding problem with automation of Word by Perl
    ... a text string and the second another text string which holds formatting ... The code works in than it opens a Word document and produces formatted text ... therein. ...
    (comp.lang.perl.misc)
  • Re: String variable read from Mysql DB + echo = Newline problem
    ... The string already has single backslash in the database. ... And BTW - you cannot exactly control formatting on the user's browser. ...
    (comp.lang.php)
  • Re: Merge Data from Access 2002 Losing Formatting
    ... formatting in a Word document into which the data is merged, ... to add formatting switches to the mergefields. ... See "Formatting Word fields with switches" on fellow MVP Graham Mayor's ... > In the database (in the table that holds the merge source ...
    (microsoft.public.word.mailmerge.fields)