Wen Jin-Chao

Hi,

We know that window can place more than one object on the system's clipboard, each representing the same information in a different clipboard format. And there is a Office clipboard.

If I copy the full contents of word document that contains lots of data in various data format, such Text, Image, OLE Object and so on. And I press Ctrl+V in Word application. How Word application put data on the clopboard and retrieval it again from clipboard without loss of format informations

Thank you for any help!



Re: Visual Studio Tools for Office How does office clipboard work?

Geoff Darst - MSFT

Hi,

Office uses the Ole clipboard which is built on top of the regular Windows clipboard. IDataObject is the mechanism by which multiple formats are supported; an object that implements IDataObject can be queried for the formats that it supports and then asked to persist its data in one of those formats. So when you do a cut or a copy in Office, the IDataObject for the source object is placed on the Ole clipboard. When a paste occurs, Office queries for the appropriate format and then asks the IDataObject for bits in that format. When you copy contents of a Word document, one of the available formats is that of the native document. When you paste back to Word, that format can be used since Word understands its own document format.

You might also be wondering about Office's ability to preserve multiple items on the clipboard. This is a completely private implementation whereby Office implements its own clipboard stack. There is no way to access this stack directly.

Sincerely,

Geoff Darst

Microsoft VSTO Team





Re: Visual Studio Tools for Office How does office clipboard work?

Wen JinChao

Thank for your detailed reply!

But if I copy a fragment of Word document first, such as text, table and other things, and I read the data from system clipboard which is not difficult. What my question is how can I read the format informations of that document fragment Is there any solution

Thank you for any help!





Re: Visual Studio Tools for Office How does office clipboard work?

Geoff Darst - MSFT

It depends on what format you are trying to read.  If you grab the IDataObject off of the OleClipboard, you can access the desired data in the desired format.  In order to read that data, you have to understand the format.  AFIK the Word document format is not documented so that won't be an option.  Your best bet would probably be to use HTML or RTF (Rich Text Format).  That will at least preserve some of the most common formatting.  The RTF specification is available at the following locations for Word 2003 and Word 2007 respectively:

http://www.microsoft.com/downloads/details.aspx familyid=AC57DE32-17F0-4B46-9E4E-467EF9BC5540&displaylang=en

http://www.microsoft.com/downloads/details.aspx FamilyID=dd422b8d-ff06-4207-b476-6b5396a18a2b&displaylang=en

From what I can tell, Word doesn't provide data as XML, but there a couple of unidentified clipboard formats that could conceivably include XML. 

Sincerely,

Geoff Darst

Microsoft VSTO Team

 





Re: Visual Studio Tools for Office How does office clipboard work?

Wen JinChao

Thanks a lot!





Re: Visual Studio Tools for Office How does office clipboard work?

SaeeStarz

When OleSetClipboard is called , how does Office clipboard know that data is available on clipboard

Does office clipboard keep reference to original IDataObject from OleClipboard or creates its own new IDataObject

I noticed that It calls GetData onmy IDataObject and then never refers to it afterwards.





Re: Visual Studio Tools for Office How does office clipboard work?

Jin RongBo

Hi,

If there are some items in the office clipboard, then we click the button "Paste All" ,we see all those items are pasted into the document,while the last one be set into the system clipboard. My question is ,does these items go directly from office clipboard to document, or it first be set to system clipboard from office clipboard ,then be pasted to ducument from system clipboard one by one

Thank you for your help!