VSTO Powerpoint Notes Page - Different colored words on same line

后端 未结 1 1086
梦谈多话
梦谈多话 2021-01-22 12:40

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

1条回答
  •  北荒
    北荒 (楼主)
    2021-01-22 13:13

    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(); } }

    0 讨论(0)
提交回复
热议问题