zoukankan      html  css  js  c++  java
  • 去掉vsto生成的任务窗格

    使用vsto对office进行二次开发时,一般会自定义任务窗格!但有时我们并不需要在打开office时都带上任务窗格。而且对于一些外部用户(没有安装office二次开发产品的用户),打开同样的文档时会弹出烦人的提示窗口。那么如何将任务窗格跟office分离呢?

    在需要的地方加上,以下代码:

    if (ServerDocument.GetCustomizationVersion(targetfilepath) == 3) ServerDocument.RemoveCustomization(targetfilepath);

    使用上面的代码要引用

    using Microsoft.VisualStudio.Tools.Applications;如下图

    注意版本

    然后再次打开保存过的文档,会发现任务窗格已经没有了!!!

    下面的是我的一个例子,我在vs2010中新建了一个“excel模板”项目,在任务窗格中添加了一个按钮,用来自定义“另存为”功能,但是用户要求是另存为后,只想看到office文档,不要任务窗格。所以有代码如下:

            private void btnSaveAs_Click(object sender, EventArgs e)
            {
                try {
                    string targetfilepath = @"D:\学习\DesignPattern\练习\WinformTest\ExcelTemplateTest\ExcelTemplateTest14.xlsx";
                    Globals.ThisWorkbook.SaveCopyAs(targetfilepath);
                    if (ServerDocument.GetCustomizationVersion(targetfilepath) == 3) ServerDocument.RemoveCustomization(targetfilepath);
                }
                catch (Exception ex) { throw ex; }
                finally {
                    Globals.ThisWorkbook.ThisApplication.UserControl = true;
                    Globals.ThisWorkbook.Close();
                    Globals.ThisWorkbook.ThisApplication.Quit();
                }
            }
  • 相关阅读:
    System.Web.HtppRuntime.cs
    Code:Tree
    Code-Helper-Web:CacheHelper.cs
    Code-Helper-Web:CookieHelper.cs
    ORACLE数据库常用查询二
    涂抹Oracle笔记2:数据库的连接-启动-关闭
    windows下常用的操作命令及dos命令
    涂抹Oracle笔记1-创建数据库及配置监听程序
    表空间满处理方法
    SQL内连接-外连接join,left join,right join,full join
  • 原文地址:https://www.cnblogs.com/jjhe369/p/2195806.html
Copyright © 2011-2022 走看看