I have this code that take all MS Word document, save it to clipboard, save clipboard to variable a finally put it back to clipboard. It all run in BackgroundWorker, but that should not be problem.
wordDoc.StoryRanges[WdStoryType.wdMainTextStory].Copy();
IDataObject originalWordDocument = null;
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => originalWordDocument = Clipboard.GetDataObject()));
...
System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => Clipboard.SetDataObject(originalWordDocument)));
The last line - specifically Clipboard.SetDataObject(originalWordDocument) throws this error:
Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))
And this
originalWordDocument.GetFormats();
return array that contains
[0] "Object Descriptor" string
[1] "Rich Text Format" string
[2] "HTML Format" string
[3] "Text" string
[4] "UnicodeText" string
[5] "System.String" string
[6] "EnhancedMetafile" string
[7] "System.Drawing.Imaging.Metafile" string
[8] "MetaFilePict" string
[9] "Embed Source" string
User contributions licensed under CC BY-SA 3.0