Copy data from ClipBoard into Rich Text Memo Field in MS Access 2007
Posted on 2009-07-08
We are trying to paste Rich Text from a WORD document programatically into a memo field in MS Access. The cut and paste works fine but when we use dataobject, the rich text formatting appears to be stripped. Do we need to explcitly define the RTF format when the data is pasted? If so, how? Also, we assume once this function pastes correctly we will be able to paste RTF direclty into a memo field that is set up for RTF.
We have 1 button (PasteFromCB) and 1 unbound text box(RTFTextBox) set to RTF format on a form. Here is the code behind the button:
Private Sub PasteFromCB_Click()
On Error GoTo Err_PasteFromCB_Click
Dim MyData As DataObject
Set MyData = New DataObject
'check to see if pasted clipboard info is text
If MyData.GetFormat(1) = False Then
MsgBox ("Data is not text. Try again.")
'Yes, clipboard is text. Continue.
Me!RTFTextBox = MyData.GetText