关闭PowerPoint加载项而不关闭PowerPoint

时间:2016-12-13 10:45:15

标签: c# interop ms-office powerpoint

我为powerpoint创建了一个加载项,但我遇到了问题。

从我的加载项关闭表单后,PowerPoint也会关闭。

我可以以某种方式关闭我的加载项而不关闭PowerPoint吗?

相同的加载项正在与OneNote一起使用而没有任何问题。 (更改了代码,使其与powerpoint一起使用)

编辑:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Extensibility;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Powerpoint;
using Microsoft.Office.Core;
using System.Windows.Forms;
using System.Runtime.InteropServices.ComTypes;
using System.IO;
using System.Drawing.Imaging;

namespace Camera_PP
{
    [GuidAttribute("38E95838-DAB6-4C56-BFF5-F55FFDD40028"),ProgId("Camera_PP.Class1")]
    public class Class1 : IDTExtensibility2,IRibbonExtensibility
    {



        public string GetCustomUI(string RibbonID)
        {
            return Properties.Resources.ribbon;
        }

        public void OnAddInsUpdate(ref Array custom)
        {

        }

        public void OnBeginShutdown(ref Array custom)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();

        }

        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {

        }

        public void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
        {


            GC.Collect();
            GC.WaitForPendingFinalizers();
        }

        public void OnStartupComplete(ref Array custom)
        {

        }
        public void showKamera(IRibbonControl control)
        {
            kamera kamera = new kamera();
            System.Windows.Forms.Application.Run(kamera);


        }
        public IStream GetImage(string imageName)
        {
            MemoryStream mem = new MemoryStream();
            Properties.Resources.icon_157351_640.Save(mem, ImageFormat.Png);
            return new CCOMStreamWrapper(mem);
        }

    }
}

这是我从中调用我的应用程序的代码。 如果我关闭kamera表单,PowerPoint也会关闭。

如果我在VS中使用vsto模板,那么一切都可以正常工作。

0 个答案:

没有答案