ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【自定义WordDocument 】

【自定义WordDocument 】

原创 Linux操作系统 作者:cckpxxxxxx 时间:2010-07-03 14:50:26 0 删除 编辑

启动VS2010

创建一个WordDocumentCSDN工程

选择创建新模板:

点击"OK"进入工程后,在WordDocumentCSDN.docx里插入七个button按钮,分别依次改名为:计算器、记事本、画图、写字板、注册表、CMD、设备管理器。以作为启动这些工具的快捷按钮;

 

分别双击button,插入下列代码

 

 

 

using System;  

using System.Collections.Generic;  

using System.Data;  

using System.Linq;  

using System.Text;  

using System.Windows.Forms;  

using System.Xml.Linq;  

using Microsoft.Office.Tools.Word;  

using Microsoft.VisualStudio.Tools.Applications.Runtime;  

using ffice = Microsoft.Office.Core;  

using Word = Microsoft.Office.Interop.Word;  

using Microsoft.Win32;  

using System.Diagnostics;  

 

namespace WordDocumentCSDN  

{  

    public partial class ThisDocument  

    {  

        private void ThisDocument_Startup(object sender, System.EventArgs e)  

        {  

        }  

 

        private void ThisDocument_Shutdown(object sender, System.EventArgs e)  

        {  

        } 

 

        #region VSTO Designer generated code  

 

        ///

  

        /// Required method for Designer support - do not modify  

        /// the contents of this method with the code editor.  

        ///

  

        private void InternalStartup()  

        {  

            this.button2.Click += new System.EventHandler(this.button2_Click);  

            this.button3.Click += new System.EventHandler(this.button3_Click);  

            this.button7.Click += new System.EventHandler(this.button7_Click);  

            this.button1.Click += new System.EventHandler(this.button1_Click);  

            this.button4.Click += new System.EventHandler(this.button4_Click);  

            this.button5.Click += new System.EventHandler(this.button5_Click);  

            this.button6.Click += new System.EventHandler(this.button6_Click);  

            this.Startup += new System.EventHandler(this.ThisDocument_Startup);  

            this.Shutdown += new System.EventHandler(this.ThisDocument_Shutdown);  

 

        } 

 

        #endregion  

 

        private void button1_Click(object sender, EventArgs e)  

        {  

            Process.Start("calc");  

        }  

 

        private void button2_Click(object sender, EventArgs e)  

        {  

            Process.Start("notepad");  

        }  

 

        private void button3_Click(object sender, EventArgs e)  

        {  

            Process.Start("mspaint");  

        }  

 

        private void button4_Click(object sender, EventArgs e)  

        {  

            Process.Start("write");  

        }  

 

        private void button5_Click(object sender, EventArgs e)  

        {  

            Process.Start("regedit");  

        }  

 

        private void button6_Click(object sender, EventArgs e)  

        {  

            Process.Start("cmd.exe");  

        }  

 

        private void button7_Click(object sender, EventArgs e)  

        {  

            Process.Start("devmgmt.msc");  

        }  

    }  

} 

using System;

using System.Collections.Generic;

using System.Data;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Xml.Linq;

using Microsoft.Office.Tools.Word;

using Microsoft.VisualStudio.Tools.Applications.Runtime;

using ffice = Microsoft.Office.Core;

using Word = Microsoft.Office.Interop.Word;

using Microsoft.Win32;

using System.Diagnostics;

 

namespace WordDocumentCSDN

{

    public partial class ThisDocument

    {

        private void ThisDocument_Startup(object sender, System.EventArgs e)

        {

        }

 

        private void ThisDocument_Shutdown(object sender, System.EventArgs e)

        {

        }

 

        #region VSTO Designer generated code

 

        ///

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        ///

        private void InternalStartup()

        {

            this.button2.Click += new System.EventHandler(this.button2_Click);

            this.button3.Click += new System.EventHandler(this.button3_Click);

            this.button7.Click += new System.EventHandler(this.button7_Click);

            this.button1.Click += new System.EventHandler(this.button1_Click);

            this.button4.Click += new System.EventHandler(this.button4_Click);

            this.button5.Click += new System.EventHandler(this.button5_Click);

            this.button6.Click += new System.EventHandler(this.button6_Click);

            this.Startup += new System.EventHandler(this.ThisDocument_Startup);

            this.Shutdown += new System.EventHandler(this.ThisDocument_Shutdown);

 

        }

 

        #endregion

 

        private void button1_Click(object sender, EventArgs e)

        {

            Process.Start("calc");

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            Process.Start("notepad");

        }

 

        private void button3_Click(object sender, EventArgs e)

        {

            Process.Start("mspaint");

        }

 

        private void button4_Click(object sender, EventArgs e)

        {

            Process.Start("write");

        }

 

        private void button5_Click(object sender, EventArgs e)

        {

            Process.Start("regedit");

        }

 

        private void button6_Click(object sender, EventArgs e)

        {

            Process.Start("cmd.exe");

        }

 

        private void button7_Click(object sender, EventArgs e)

        {

            Process.Start("devmgmt.msc");

        }

    }

}

 

按下F5开始调试

 

执行效果如下,我们的文档打开了以后,文档内嵌了包括计算器、记事本、画图、写字板、注册表、CMD、设备管理器多个按钮

在书写文档中,需要用到计算器,我们顺便点击文档中"计算器"就可以把计算器快捷呼出:

其他各功能快捷按钮用法如上所同。

 

21.JPG

22.JPG

23.JPG

24.JPG

25.JPG

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9914489/viewspace-667084/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-07-03

  • 博文量
    1
  • 访问量
    1340