Copy Text from Notes RTF into MS Word File

Author: Tripp W Black

Created: 08/09/2001 at 06:32 PM

 

Category:
Notes Developer Tips
LotusScript

Possibly the cleanest way is to write the content of the rich text field to a file, and then open it via word. Although you can export a document to an RTF file, you can't save a rich text field as a file. (Of couse you can open the doc with a different form, save the doc as the RTF file etc, but we are back to a clumsy approach).

Certainly the easiest way is via the clip board. Here is my code...


Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim MsWord As Variant
Dim WordDoc As Variant

'Get the current document and copy the rich text field (body) to the clip board
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
uidoc.EditMode = True
Call uidoc.GotoField("Body")
Call uidoc.Selectall
Call uidoc.Copy

'Create the doc in Word
Set MsWord = CreateObject("Word.Application")
MsWord.Visible = True
Call MsWord.Documents.Add
Set WordDoc = MsWord.ActiveDocument

'Paste the rich text from the clip board
Dim mainStory As Variant
Set mainStory = WordDoc.StoryRanges(1)
mainstory.paste
End Sub


previous page