Has Microsoft added the 'keep source formatting' via the powerpoint API? RRS feed

  • Question

  • I am trying to add single slides from files into a larger powerpoint presentation.

    I am using InsertFromFile(), but i cannot find a way to carry over all formatting. There is a simple checkbox in the gui 'keep source formatting'.

    Why is this not available in the API?

    I have found some that try and manually copy over the formatting, this sounds like trouble in the making. Does slide.copy() really use the clipboard of the machine???


    Sunday, September 2, 2012 9:55 PM

All replies

  • Hi Jimbit,

    Thank you for posting in the MSDN Forum.

    Could you please show your presentation if possible? I've tried code below, actually using the method InsertFromFile() you've mentioned.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Office = Microsoft.Office.Core;
    using PPT = Microsoft.Office.Interop.PowerPoint;
    namespace ConsoleApplication_PPT_InsertSlide
        class Program
            static void Main(string[] args)
                //A ppt with single slide in it. Font set to red italic and bold.
                string fNameOrigin = @"D:\Origin.pptx";
                //With 3 slides in it.
                string fNameFinal = @"D:\Final.pptx";
                PPT._Application myAPP1 = new PPT.Application();
                PPT._Application myAPP2 = new PPT.Application();
                myAPP1.Visible = Office.MsoTriState.msoTrue;
                myAPP2.Visible = Office.MsoTriState.msoTrue;
                PPT.Presentation myPPT1 = myAPP1.Presentations.Open(fNameOrigin, 
                    Office.MsoTriState.msoTrue, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
                PPT.Presentation myPPT2 = myAPP1.Presentations.Open(fNameFinal, 
                    Office.MsoTriState.msoTrue, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
                myPPT2.Slides.InsertFromFile(fNameOrigin, 2, 1, 1);

    The font color and font style kept well in the Final presentation. What format setting do you have in your presentation?

    There's a Slide.Copy() method, however I've found no way to paste so far.

    Hope it helps.

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Quist ZhangModerator Monday, September 10, 2012 12:42 AM
    • Unmarked as answer by jimbit Monday, September 10, 2012 1:21 AM
    Tuesday, September 4, 2012 12:11 PM
  • This was definitely NOT the answer.

    1.  the work around i used is listed here: other thread

    you will see my reply on the bottom with the code snippet. However if i copy over the 'CustomLayout' of the source slides you cannot save the file.

    The question for this thread is:  since there is a simple checkbox when importing slides called 'keep source formatting':  Why doesn't the API also allow to use this flag?

    edit: also, please dont come with copy and paste options..... does 'copy()' really use the machines clipboard??? what if someone else is using the machine when your program is running. crazy.


    • Edited by jimbit Monday, September 10, 2012 1:29 AM
    Monday, September 10, 2012 1:27 AM
  • Hi Jimbit,

    Unfortunately, Slide.Copy Method use the machines' clipboard.

    I've opened up a notepad and typed some words, then I selected them all and pressed Ctrl+C.

    After I compiled a program with Slide.Copy in it, I cannot paste those words I've copied before. I opened word and pressed Ctrl+V, all I can see is a slide.

    It's hard to use a clipboard with out interfere the user.



    Monday, September 10, 2012 3:03 AM