Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi legends,
I am currently working for Word and PowerPoint Add-ins in c#. In Word file I used Interop to insert content control at current cursor position, but for PowerPoint file there is no option to insert content control from OOTB and also programatically as per my research of two days.

Is there any alternative to accomplish inserting content control or text in PowerPoint at current cursor position?

For Word file I have used this below code snippet
C#
private void AddRichTextControlAtSelection(string contentControlName)
    {
        try
        {
            Microsoft.Office.Interop.Word.Document currentDocument = Globals.ThisAddIn.Application.ActiveDocument;                
            currentDocument.ActiveWindow.Selection.Select();

            Microsoft.Office.Tools.Word.Document extendedDocument = Globals.Factory.GetVstoObject(currentDocument);

            richTextControl1 = extendedDocument.Controls.AddRichTextContentControl("rtc_" + Guid.NewGuid().ToString());
            richTextControl1.PlaceholderText = contentControlName;
            richTextControl1.Title = contentControlName;
            richTextControl1.Tag = contentControlName;
        }
        catch (Exception ex)
        { }
    } 
Posted

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