Copy/Paste Formatted text from TextNote to clipboard

Copy/Paste Formatted text from TextNote to clipboard

pschleppy
Explorer Explorer
1,156 Views
4 Replies
Message 1 of 5

Copy/Paste Formatted text from TextNote to clipboard

pschleppy
Explorer
Explorer

I am trying to copy the content of the TextNote into Clipboard. Currently I have following code. The code copies text into clipboard without formatting. Is there a way to copy content of a TextNote along with its formatting?

 

var elem = doc.GetElement(pickedRef);
var textNote = elem as TextNote;
System.Windows.Clipboard.SetData(System.Windows.TextDataFormat.Text.ToString(), textNote.Text);

 

0 Likes
1,157 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Paul,

 

Thank you for your query.

 

TextNote.GetFormattedText?

 

http://www.revitapidocs.com/2017/a1e3b2d7-0d56-55f9-6b30-1c5269dc39e0.htm

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 5

pschleppy
Explorer
Explorer

What is data format of data in FormattedText class? I would like users to be able to copy the data to MS Word.

0 Likes
Message 4 of 5

solvedplus
Contributor
Contributor

hi,

i have tried all options of formatted text with clipboard but text with format can't be copied to clipboard

what do we miss?

thanks

 

0 Likes
Message 5 of 5

gdavis479JP
Contributor
Contributor

Here is the code that seems to work.  Originally got the idea from Martin Schmid (thanks)... Googled to find how again and found this forum entry (which often are incomplete), so now that I further researched - here it is...

Not 100% sure which of these two are need (or both) but using...

using System.Windows;

using System.Windows.Forms;

 

INSIDE YOUR CODE... where:

string catalogProductItemInfo = "The string of text you want to go to clipboard (or other variable - text info etc)";

call this:

Clipboard.SetText(catalogProductItemInfo);

0 Likes