Group: microsoft.public.word.vba.general
From: "Klaus Linke"
Date: Thursday, March 13, 2008 3:57 PM
Subject: Re: Copy and Paste RTF string

> How do you do that? For some reason my search term
> "VBA save rtf file" is not very helpful.


Quick and dirty/not debugged:

Sub RTF_Place(sText As String)
Dim iFile As Integer
iFile = FreeFile
Open "C:\Windows\Temp\temp.RTF" For Binary As #iFile
Put #iFile, , sText
Close #iFile
Selection.InsertFile FileName:="C:\Windows\Temp\temp.rtf", Range:="", _
ConfirmConversions:=False
Kill "C:\Windows\Temp\temp.RTF"
End Sub

Sub Test_RTF_Place()
Dim sText As String
sText = "{\rtf1\ansi\ansicpg1252\deff0\deftab360{\fonttbl{\f0\fswiss
Arial;}{\f1\fswiss\fcharset0 Arial;}}{\*\generator Riched20
5.50.99.2050;}\viewkind4\uc1\pard\f0\fs20\lang1033\par\par\f1 TEST\f0\par}"

Call RTF_Place(sText)

End Sub

If you plan to use the macro on several computers, it might be a good idea
to google for a safe way to determine the Temp folder... or maybe just use
the current folder -- you'll delete the file anyway.

Regards,
Klaus