Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear the MS Office Clipboard using c# Word Interop

I'm working with Word Interop to copy an entire document to do some logic. After I'm done, I want to clear the MS Office clipboard. This seems like a simple task... but I can't figure out how to do it.

var that = document.ActiveWindow.Selection;
that.WholeStory();
that.Copy();
// Do some logic with the selection
...
// Now I want to clear the MS Office clipboard.

Note 1: Clipboard.Clear() only clears the system-wide clipboard, but does not clear MS Office's clipboard.

Note 2: I realize that copying a document isn't the best way to work with the Document object, once I figure out this issue, I'll work on better logic.

like image 921
Joe W Avatar asked Nov 12 '22 11:11

Joe W


1 Answers

The Office Clipboard is not exposed to the developer - there's no way to clear it, or to place any content specifically on it, or to "read" what it contains.

Whether there's a "better way" to copy a Word document depends very much on what you want/need to do with the content...

like image 72
Cindy Meister Avatar answered Nov 15 '22 05:11

Cindy Meister