Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: clipboard Interop
I am having an issue copying clipboard data from OneNote 2010. I would like to be able to copy the clipboard, serialized it and paste it back in. But it always loses its formatting (OneNote HTML..) so the text and images are not arranged in the way that they were copied. I'm just using the .NET Clipboard class and the IDataObject Interface. Thanks for any help.
 

 

Here Is an Example:
  public partial class Form1 : Form
  {
    IDataObject clipboard;
 
    public Form1()
    {
      InitializeComponent();
 
    }
 
    private void getButton_Click(object sender, EventArgs e)
    {
      clipboard = Clipboard.GetDataObject();
      for (int i = 0; i < clipboard.GetFormats(true).Length; i++)
      {
        chatHist.Text += clipboard.GetFormats(true)[i] + Environment.NewLine;
      }
 
    }
 
    private void sendButton_Click(object sender, EventArgs e)
    {
      Clipboard.Clear();
      Clipboard.SetDataObject(clipboard);
    }
 
  }
 
Formats Returned:
OneNote 2010 Internal
Ink Serialized Format
HTML Format
System.String
UnicodeText
Text
EnhancedMetafile
DeviceIndependentBitmap
 
Image:
Image
Posted 9-Jul-12 7:21am
Edited 25-Jul-12 8:43am
v7
Comments
Richard MacCutchan at 9-Jul-12 14:23pm
   
You need to show the code that you are using so people can advise what, if anything, you are doing wrong. Also be specific about the problem, explain the exact data that is on the clipboard and show what you get out of it.
cswimmer at 10-Jul-12 15:41pm
   
Hi Richard, Thanks for the advice, I've gone ahead and included more information.
Richard MacCutchan at 10-Jul-12 16:05pm
   
It looks like the data is copied but you are losing some formatting information within your code. This is possibly a Microsoft Office issue, as I know they have some extra features in cut and paste.
cswimmer at 23-Jul-12 13:01pm
   
*BUMP*
Would it be possible to use OneNote Interop to do this? I was reading about the GetBinaryPageContent Method of that API, which returns all the data of a chosen page in OneNote XML format. Is there some way I could extract my selection from the XML and persist it?
Thanks,
-cswimmer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 Maciej Los 210
4 PIEBALDconsult 184
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 25 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100