Solved

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

Posted on 2009-07-08
8
1,059 Views
Last Modified: 2013-11-27
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
0
Comment
Question by:Savtek_com
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:VijayprakashM
ID: 24806094
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
 

Author Comment

by:Savtek_com
ID: 24806546
Thanks for the suggestion but our project requires that we stay in Access 2007.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24807793
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
 

Author Comment

by:Savtek_com
ID: 24808131
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24809873
Why not just link to the Word Document directly?
0
 

Author Comment

by:Savtek_com
ID: 24810266
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
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 24810411
...may not be possible

;-)

Jeff
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24850584
;-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now