I am trying to insert content into the Notes Page of Powerpoint programmatically. There will be different colored text on the same line. I have only gotten it to work via paragr
So I've spent a fair bit of time on this looking for a more elegant solution..... but this is the best I have found.... This assumes that you have your text formatted in HTML, but there is a marked section to start if you already have a RTF format.
var html = "--Example CommendSELECTTOP 1 COALESCE(ASPU.MobileAlias, ASPU.UserName)AS UNameFROM dbo.aspnet_Users ASPU
";
var title = "Header Text";
if (!string.IsNullOrWhiteSpace(html))
{
var web = new WebBrowser();
web.CreateControl();
web.DocumentText = html;
while (web.DocumentText != html)
{
System.Windows.Forms.Application.DoEvents();
}
web.Document.ExecCommand("SelectAll", false, null);
web.Document.ExecCommand("Copy", false,
//Start here if you already have it in RTF.
var rtf = Clipboard.GetData(DataFormats.Rtf) as string;
if (!string.IsNullOrWhiteSpace(rtf))
{
slide = ppt.Slides.AddSlide(ppt.Slides.Count + 1, ppt.SlideMaster.CustomLayouts[1]);
slide.Layout = PpSlideLayout.ppLayoutTextAndObject;
slide.Shapes.Title.TextFrame.TextRange.Text = title;
slide.Select();
slide.Shapes[2].Select();
Globals.ThisAddIn.Application.CommandBars.ExecuteMso("PasteSourceFormatting");
System.Windows.Forms.Application.DoEvents();
}
}