Microsoft KB Archive/97619

= FIX: OLE Client: Copying Linked Object Gives Err: Can't Paste =

Article ID: 97619

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Windows 2000 Readiness Analyzer

-



This article was previously published under Q97619



SYMPTOMS
If you use the OLE client control to paste a linked OLE object onto the clipboard and then later copy the same OLE object from the clipboard back to the OLE client control, you may see this error message:

Can't Paste

This occurs whether the linked OLE object is created from an existing file (OleClient1.Action = 1) or from an OLE object on the clipboard (OleClient1.Action = 4). This problem occurs only with a linked object, not with an embedded object.



STATUS
Microsoft has confirmed this to be a bug in both the Standard and Professional Editions of Microsoft Visual Basic version 2.0 for Windows and in the Microsoft Professional Toolkit for Visual Basic programming system version 1.0 for Windows. This bug was corrected in Visual Basic version 3.0 for Windows.



MORE INFORMATION
The following example uses Microsoft Excel version 4.0 as the application associated with the OLE object, however the bug does not depend on Excel; it occurs no matter which application is associated with the OLE object.

Steps to Reproduce Problem
 Start Microsoft Excel. The Sheet1 worksheet is created by default. In the R1C1 cell, enter Fixed Assets. From the Edit menu, choose Copy (ALT+E+C). Start Visual Basic or from the File menu, choose New Project (ALT+F+N) if Visual Basic is already running. Form1 is created by default. From the File menu, choose Add File. In the Files box, select the OLECLIEN.VBX custom control file. The OLE client tool appears in the Toolbox. Add an OLE client control (OleClient1) to Form1.</li> Add a command button (Command1) to Form1.</li>  Add the following code to the Command1_Click event: Sub Command1_Click Const OLE_LINKED = 0 Const OLE_COPY = 4 Const OLE_PASTE = 5 Const OLE_UPDATE = 6 Const OLE_DELETE = 10

If OleClient1.PasteOK Then OleClient1.Protocol = &quot;StdFileEditing&quot; OleClient1.ServerType = OLE_LINKED OleClient1.Action = OLE_PASTE ' Get object from clipboard OleClient1.Action = OLE_COPY  ' Copy the object back onto the ' clipboard OleClient1.Action = OLE_UPDATE ' Display object OleClient1.Action = OLE_PASTE ' Attempt to paste the ' object onto the clipboard OleClient1.Action = OLE_DELETE Else MsgBox &quot;Contents of the Clipboard in unacceptable format&quot; End If  End Sub </li> From the Run menu, choose Start (ALT+R+S) to run the program.</li> Click the Command1 button. It should work, but instead the program stops and gives the &quot;Can't paste&quot; error message. The Excel object is successfully linked to OleClient1 and displayed, and the linked object is also copied successfully onto the clipboard.</li></ol>

Additional query words: 1.00 2.00 3.00 errmsg buglist1.00 buglist2.00 fixlist3.00

Keywords: kbbug kbfix KB97619

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.