This post originated from an RSS feed registered with .NET Buzz
by Anand M.
Original Post: Inserting Rich Text into PowerPoint
Feed Title: .NET From India
Feed URL: http://www.dotnetindia.com/index.rss
Feed Description: Your daily dose of .NET From India
I was trying to programmatically insert some rich text into a specific text box in PowerPoint.
I had a rich text box in a winform application that had some formatted text. I wanted this to be moved into a specific textbox in my PPT.
The first approach I tried was to set the text directly:
txt.TextFrame.TextRange.Text=rtfbox.Rtf
Â
But then the actual rich text markups were copied into the text. So the incoming data was getting interpreted as normal text. Makes sense..
So the next I tried was to copy the data from the richtext and then pasting it into the frame. When you do this manually, PowerPoint recognizes the format and pastes the data as formatted text.
Now I started getting a strange error â "The specified value is out of range." - when the Paste command executes.
After some changing of options and a search that did not yield any results, I suddenly thought, maybe if I force the clipboard type to be RTF then it may work. Yep it did.