FIX: OLE Client: Copying Linked Object Gives Err: Can't Paste
ID: Q97619
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for Windows, version 2.0
-
Microsoft Professional Toolkit for Visual Basic programming system for Windows, version 1.0
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.
- Add a command button (Command1) to Form1.
- 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 = "StdFileEditing"
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 "Contents of the Clipboard in unacceptable format"
End If
End Sub
- From the Run menu, choose Start (ALT+R+S) to run the program.
- Click the Command1 button. It should work, but instead the program
stops and gives the "Can't paste" error message. The Excel object is
successfully linked to OleClient1 and displayed, and the linked object
is also copied successfully onto the clipboard.
Additional query words:
1.00 2.00 3.00 errmsg buglist1.00 buglist2.00 fixlist3.00
Keywords :
Version :
Platform :
Issue type :