Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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
Updated 25-Jul-12 7:43am
v7
Comments
Richard MacCutchan 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.
calebboyd 10-Jul-12 15:41pm    
Hi Richard, Thanks for the advice, I've gone ahead and included more information.
Richard MacCutchan 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.
calebboyd 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900