Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy from Word to a Memo Field in a Table? 1

Status
Not open for further replies.

Quintios

Technical User
Mar 7, 2002
482
US
I have a memo field in my database with a bunch of text in them. I would like to search and replace the text; however, Access crashes every time I try to accomplish this. So I set up a module to copy the code out of the field in question, paste it into MS Word, do the search and replace there, and then... well, that's where I'm stuck. Once I've cut and placed text on the clipboard, how do I paste it back into a field? Here's the final bit of code:

Code:
Set rsTemplate = db.OpenRecordset(sqlstring...)
With rsTemplate

'bunch of code...
'bunch of code...

    With .Selection
        .WholeStory
        .Cut
    End With

OK, so now that the text in Word has been selected and cut, how do I paste it into the field 'CodeTemplate'? I would assume it's some sort of edit to the recordset, perhaps:

Code:
    .Edit
    !CodeTemplate = ???
    .Update

What do I set '!CodeTemplate' equal to?

Thanks in advance,
Onwards,

Q-
 
The following will perform a paste action to a form object if it has the focus. Not sure if you are performing this one record at a time from a Form or not. But, if you are set the focus back to the form object me!codetemplate and try the following command. I haven't tried this but I believe it should paste the contents of the clipboard to your object thus updating it with new string of data.

DoCmd.RunCommand acCmdPaste

Let us know if it works.

Bob Scriver
 
Yeah, I found that in the MSDN library for Office 2000. Unfortunately, what I'm doing is running through a recordset for a table, essentially the entire table for that matter, and updating the memo field in each record. I'm not sure how to automate this using a form.

I did find, however, some code for copying from the clipboard to a memo field. It involves (which is obvious to me now but was not obvious before) using the Windows API. The code can be found at the Knowledgebase, article Q210213 for retrieving information from the clipboard, and article Q210216 for sending information to the clipboard.

Works well, in the end, using the code from those articles, I end up with:

Code:
With rsTemplates

    'bunch of code

    .Edit     'Set the recordset for editing
    .Fields("CodeTemplate") = ClipBoard_GetData()
    .Update   'Update the recordset with the new data
end with

I find that usually everything I need is in the Knowledgebase, eventually. Stuff just isn't very easy to find. Fortunately I have an MSDN subscription where I get the Libraries on CD. I'm still on dialup..

Here's a star for you anyway, thanks for the suggestion!
Onwards,

Q-
 
I appreciate the star and also the information about the

ClipBoard_GetData() function. Am about to start converting to ACCESS 2k and will need all this type of stuff.

Bob Scriver
 
I'm using Access 97 and the code works fine how I'm using it. I hope that 2000 and/or 2002 are more stable when it comes to searching and replacing text within a field, as opposed to replacing entire fields. This is the whole reason why I had to spend a couple hours writing, testing, and debugging the code (by the way, the MAXSIZE constant is very small, considering I'm using it on memo fields).

This is getting off the subject, but I'd be very interested to hear what sort of things you're running into when converting to Access 2000. I don't know if there's a website out there (haven't looked, to be truthful) with a "FAQ of What Happens When Your Nice 97 DB has to go to 2000", but I know that it would be great to hear about your experiences here. Maybe post a FAQ when all is said and done? Or maybe just email me? :)

We'll be going to Office XP next year, so the DB I'm creating will have to be converted. I assumed I'd have to convert all my DAO stuff to ADO, but from what I understand DAO is faster anyway, and if I just keep the correct references what does it matter anyway? The db is a standalone product that does not interface with anything but itself. Anyway, I better stop before I ramble on for an hour here.

LET US KNOW WHAT YOU FIND OUT. :)

Onwards,

Q-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top