ACC1x: Cannot Paste Data from Clipboard Using DDEID: Q104682
|
When you attempt to paste data into a dynamic data exchange (DDE) server
application from Microsoft Access, the process does not complete correctly
and the following error message is generated:
The other application won't perform the DDE method or operation you attempted.
Microsoft Access does not "render," or place, the data on the Clipboard until an application requests the data for pasting. (This technique provides improved performance with large pieces of data.) When Microsoft Access issues the DDEExecute command to tell the DDE server application to paste the data, it waits for that command to finish before allowing any other operation to take place. When the DDE server application receives the paste command, it requests that Microsoft Access place the data on the Clipboard. However, Microsoft Access will not do this because it is waiting for the DDEExecute command to finish.
The following sample Access Basic function called RenderClipboard() can be
called to force Microsoft Access to render the data to the Clipboard before
issuing the DDEExecute command:
NOTE: This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information on Access Basic, please refer
to the "Introduction to Programming" manual.
NOTE: You may have some Microsoft Windows API functions defined in an
existing Microsoft Access library; therefore, your declarations may be
duplicates. If you receive a duplicate procedure name error message, remove
or comment out the declarations statement in your code.
NOTE: In the following sample code, an underscore (_) is used as a line-
continuation character. Remove the underscore when re-creating this code in
Access Basic.
'*********************************************************
' MODULE DECLARATION SECTION
'*********************************************************
Declare Function OpenClipboard% Lib "User" (ByVal hWnd%)
Declare Function GetClipboardData% Lib "User" (ByVal wFormat%)
Declare Function CloseClipboard% Lib "User" ()
Global Const CF_TEXT = 1
Function RenderClipboard ()
Dim RetVal As Integer
RetVal = OpenClipboard(0)
RetVal = GetClipboardData(CF_TEXT)
RetVal = CloseClipboard()
End Function
Function CopyRecordToWinword ()
Dim RetVal, Chan
' Copy the current record to the clipboard
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY
RetVal = RenderClipboard()
Chan = DDEInitiate("winword", "Document1")
DDEExecute Chan, "[EditPaste]"
DDETerminate Chan
End Function
Caption: Copy to Record
OnPush: =CopyRecordToWinword()
Microsoft has confirmed this to be a problem in Microsoft Access versions 1.0 and 1.1. This problem no longer occurs in Microsoft Access version 2.0.
Function CopyRecordToWinword ()
Dim RetVal, Chan
' Copy the current record to the clipboard
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY
Chan = DDEInitiate("winword", "Document1")
DDEExecute Chan, "[EditPaste]"
DDETerminate Chan
End Function
Caption: Copy to Record
OnPush: =CopyRecordToWinword()
Function CopyRecordToExcel ()
Dim RetVal, Chan
' Copy the current record to the clipboard
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_SELECTRECORD
DoCmd DoMenuItem A_FORMBAR, A_EDITMENU, A_COPY
Chan = DDEInitiate("Excel", "Sheet1")
DDEExecute Chan, "[Paste()]"
DDETerminate Chan
End Function
Keywords : kbinterop
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: March 25, 1999