none
How to put my .pptx file in my VSTO project and the use it ? RRS feed

  • Question

  • Hello everyone !

    I would like to know if it is possible to open a powerpoint presentation files which is in my solution projects. I have a macro who open the active presentation actually, but I would like to put my powerpoint presentation in my add-in, then I can open it and add slides with custom layouts. I want to do this because I would like to have only one file : Actually, I got my add-in to install, and then I use my presentation to edit. 

    I hope someone can help !

    Regards

    Friday, April 20, 2018 1:41 PM

Answers

  • Hi TomRichardLim,

    For your requirement, I suggest you follow steps below:

    1. Right Click your project->Add Existing Item-> Choose your PPTX file

    2. Turn to the pptx file property, Set Build Action as Content

    3. Change the file path like below:

            private void Load_Click(object sender, RibbonControlEventArgs e)
            {
                //System.Diagnostics.Debugger.Launch();
                string FileName =Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase) + @"\Test.pptx";
                Globals.ThisAddIn.Application.Presentations.Open(FileName);
            }
    

    4. Publish your AddIn by ClickOnce,

    5. install the addin and try the function.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by TomRichardLim Tuesday, April 24, 2018 8:06 AM
    Tuesday, April 24, 2018 6:50 AM

All replies

  • Hi TomRichardLim,

    Did you try to get the current object of PowerPoint and open the existing presentation in it?

    If not you can try to check that. It may help you to solve your issue.

    obj = System.Runtime.InteropServices.Marshal.GetActiveObject("PowerPoint.Application");

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 23, 2018 8:28 AM
    Moderator
  • Hi Deepak,

    Thank you for your answer !

    I understand what you mean, and actually I can acces to my Powerpoint application, with another command :

    ActivePresentation = Globals.ThisAddIn.Application.ActivePresentation

    This is the way I get my active presentation, and it works. I can also use the Powerpoint.Presentations object to open a file, like this :

    Globals.ThisAddIn.Application.Presentations.Open(FileName)

    But actually, this command needs a filenam, who is the path of the file. But I can't access to the file into my ressources with a path. I am trying actually to copy my file into the temporary folders of the computer, then open it. What do you think about this solution ?

    I will try to see if there is another functions that appears with your command.

    Regards,

    TomRichardLim

    Monday, April 23, 2018 9:50 AM
  • Hi TomRichardLim,

    For your requirement, I suggest you follow steps below:

    1. Right Click your project->Add Existing Item-> Choose your PPTX file

    2. Turn to the pptx file property, Set Build Action as Content

    3. Change the file path like below:

            private void Load_Click(object sender, RibbonControlEventArgs e)
            {
                //System.Diagnostics.Debugger.Launch();
                string FileName =Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase) + @"\Test.pptx";
                Globals.ThisAddIn.Application.Presentations.Open(FileName);
            }
    

    4. Publish your AddIn by ClickOnce,

    5. install the addin and try the function.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by TomRichardLim Tuesday, April 24, 2018 8:06 AM
    Tuesday, April 24, 2018 6:50 AM
  • Thanks ! It works !
    Tuesday, April 24, 2018 8:06 AM