Copy data from ClipBoard into Rich Text Memo Field in MS Access 2007

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
    MyData.GetFromClipboard
    If MyData.GetFormat(1) = False Then
        MsgBox ("Data is not text.  Try again.")
        GoTo Exit_PasteFromCB_Click
    End If
   
    'Yes, clipboard is text.  Continue.
    Me!RTFTextBox = MyData.GetText
 
Exit_PasteFromCB_Click:
    Exit Sub
   
Err_PasteFromCB_Click:
    MsgBox Err.Description
    Resume Exit_PasteFromCB_Click
 
End Sub
Savtek_comAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VijayprakashMCommented:
Get the clip board data to a simple text

Further what you need to do to get the text data into rich text memo field in ms access 2007 is use Xbasic
Using Xbasic you can play with RTF object,Xbasic can manipulate data in variables and in RTF memo fields.Create a temporary RTF object you can use RTF.CREATE() method.

Please go through the link below for step by step process

http://support.alphasoftware.com/alphafivehelpv8/Xbasic/Working_with_RTF_Data.htm
0
Savtek_comAuthor Commented:
Thanks for the suggestion but our project requires that we stay in Access 2007.
0
Jeffrey CoachmanMIS LiasonCommented:
Savtek_com,

This is very difficult to do.

1. <when we use dataobject>
First things first.
What happens if you simply copy and paste from Windows?

2. Stumbling block:
Access 2007 *DOES NOT* true Rich text, it uses HTML formatting.
Word used True Rich Text.
I will assume that this is why your Copy/Paste code does not work properly.

3. In Access 2007 you can format the data once it is in the Database (table), however, you cannot insert RTF or HTML formatted data (Like in my screenshot) into the table directly, and have it display in the Form/Report formatted.

Please remember that the data stored in a database really has no format, it is raw data, you can apply formatting, to make it look a certain way, but the stored data contains no formatting.
This is why this is so tricky.

There are HTML and Rich text controls out there that you can play with. But again, you may need to do a lot of  Filp-Flopping with the Code and character formatting to pull this off.

JeffCoachman

untitled.JPG
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Savtek_comAuthor Commented:
Jeff,
Thanks for the response.  Let me clarify a few things:

1) The problem we are having is not an issue between rtf and html.  Yes, some formatting is not kept after pasting such as tables, etc. but in general it looks pretty good.

2) Using Windows to copy an entire WORD document and then pasting the clipboard into an Access memo field works fine and keeps the formatting.  The problem is if the WORD document is larger than 65000 characters, the data is truncated to this maximum amount.  The formatting looks great but we lose half of our data.

3) We have, however, successfully copied the entire WORD document when it is greater than 65000 characters (ours is 131000) using the code initially submitted but unfortunately all the formatting is stripped from the data.

So, it seems we can either keep the formatting but have a shortened document or keep the entire document but have no formatting.  Selfishly we are trying to do both.

Any further ideas?
0
Jeffrey CoachmanMIS LiasonCommented:
Why not just link to the Word Document directly?
0
Savtek_comAuthor Commented:
Yes, another good idea but we link to Word, excel and pdf documents in this application already and it works extremely well.  For this particular document, they want to view it along with other data that is entered in the same table /memo field without opening up another application, i.e. Word.  And what the client wants...
0
Jeffrey CoachmanMIS LiasonCommented:
...may not be possible

;-)

Jeff
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.