How to Copy and Paste RTF Formatted Text into a Word Document

Hi
I have an Access 2000 database that merges phrases into a Word template using Word automation. I want to use RTF formatting so have decided to use copying and pasting from the clipboard within one of my routines(this is due to having tried saving RTF formatted text and not being able to bring it back formatted). I am having trouble copying RTF formatted text to the clipboard using VBA. I have tried MS's Clipboard_SetText routines and others but they just bring back the whole of the RTF code (e.g. {\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\froman\fprq \fcharset0 Times New Roman;}{\f1\fnil\fcharset0 MS Sans Serif;}} \viewkind4\uc1\pard\lang2057\b\f \fs24 To be bold\b0\f1\fs17 \par }).

Are there any VBA routines that copy RTF text to the clipboard and then can be pasted in their formatted way? E.g. if I have "I am bold" in the RTF, it pastes as "I am bold" in a bold font.  

(NB. if there is a .NET way of doing this then that would be a second option if not VBA)

Thanks for your help.
gycitsupportAsked:
Who is Participating?
 
gycitsupportConnect With a Mentor Author Commented:
My replacement of "^c" worked for what I required. Thanks,
0
 
tbsgadiCommented:
Hi gycitsupport,

Have a look at http://www.lebans.com/richtext.htm.
It also has a regular text feature

Good Luck!

Gary
0
 
gycitsupportAuthor Commented:
Hi
Thanks for that. I was really hoping to do it without a third party add-on as it really wouldn't be suitable. I can generate my rich text but it's the putting it into the clipboard that is the issue.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
peter57rCommented:
I don't think I understand your starting point.

Access 2000 does not have any rich text capability, so how are you storing rich text in your database unless you are already using third party tools?


0
 
gycitsupportAuthor Commented:
Hi
I am using the Microsoft RichTextBox Control 6 to generate my RTF.
0
 
rockiroadsCommented:
Could you not use a hidden rtf control to use as your clipboard?
0
 
tbsgadiCommented:
FYI with Lebans RTF you don't need to generate any code, it works just like Word.
0
 
Gustav BrockCIOCommented:
So you didn't succeed with the methods for moving data via the the clipboard, Copy and PasteSpecial:

http://www.experts-exchange.com/Programming/Languages/.NET/Q_23874694.html#a22885276

/gustav
0
 
gycitsupportAuthor Commented:
Hi
I think I've managed to finally solve the problem. It involves using a clipboard_setdata routine and then find and replace using the clipboard. replacing with "^c".  I'm still trying to finalise the issue and make it work 100% of the time, but progress is being made.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.