Microsoft KB Archive/141440

= PRB: Paste Link Fails in Microsoft Excel =

Article ID: 141440

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 1.52 Professional Edition

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 2.0 Professional Edition</li></ul>

 Microsoft Visual C++ 2.1</li></ul>

 Microsoft Visual C++ 6.01 Professional Edition</li></ul>

 Microsoft Visual C++ 4.0 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Learning Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q141440

<div class="symptoms_section">

SYMPTOMS
After you attempt to use Paste Link to paste the clipboard contents into Microsoft Excel, Microsoft Excel fails and displays a warning:

Unable to paste link.

<div class="cause_section">

CAUSE
When Microsoft Excel attempts to paste link an object, it looks for a full moniker for the object (OLEWHICHMK_OBJFULL). The full moniker consists of the moniker of the object's container (OLEWHICHMK_CONTAINER) and the moniker of the object relative to its container (OLEWHICHMK_OBJREL). In MFC, if SetItemName is not used to provide a name for the COleServerItem, the OLEWHICHMK_OBJREL portion of the moniker cannot be provided. This causes Paste Link to fail in Microsoft Excel.

<div class="resolution_section">

RESOLUTION
Set the name of the item to be paste linked by using the SetItemName function. The sample code in this article illustrates one way you might do this.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce Behavior
This behavior seems to be unique to Microsoft Excel but may exist in other applications as well.

Run the scribble application (step 7) and save a document. In scribble, on the Edit menu, click Copy to copy the document object and metafile representation to the clipboard. Run Microsoft Excel, choose Paste Special, and select the Paste Link option. Attempt to use Paste Link to paste the Scrib Document Object or the "Picture." Microsoft Excel will not succeed and will display a warning:

Unable to paste link.

Sample Code
In the case of scribble, the following code will fix the problem CScribItem::CScribItem(CScribDoc* pContainerDoc) : COleServerItem(pContainerDoc, TRUE) {   SetItemName("Scribble Item"); }

<div class="references_section">