Tag: Office2007
Begin to VSTO
by Charlie on May.17, 2008, under VSTO
see in Chinese version 中文版 http://www.5ushare.com/vsto/vsto-%e4%b9%8b-%e5%88%9d%e5%a7%8b%e7%af%87.html
After installed VSTO,then you can use it.Here, i only give a a simple introduction VSTO project establishment and simple development to you.The concrete development and the skills,i will make the introduction later.
The tools i used are VS2005 and Office2007 ,the programming language is C#.
If you have installed the VSTO.Open VS2005, [...]
VSTO 之 初始篇
by Charlie on May.13, 2008, under VSTO
安装完VSTO,便进入了它的使用过程。这里,只简单的介绍一下VSTO工程的建立及简单的开发。具体开发及技巧,将在以后做出介绍。在这里,我用是VS2005+Office2007,语言为VC#。
安装完VSTO后,打开VS2005,单击打开新建工程项,便能看见如下窗口。
以PowerPoint为例。新建一个“PowerPoint 外接程序”工程。这是,将产生一个ThisAddIn.cs文件。里边分别由如下两个函数
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
于是,每回PowerPoint被打开时,都会运行private void ThisAddIn_Startup(object sender, System.EventArgs e)。后一个函数则是析构函数。这样,只要将咱们的代码加入第一个函数,便实现想要的效果了。
这里还是举一个简单的例子。每回打开一个文档时,对这个文档进行关键字的搜索。代码大致如下,其中细节问题会在以后有所介绍。
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
//Monitor the event of Open a Presentation and save
this.Application.PresentationOpen +=
new Microsoft.Office.Interop.PowerPoint.EApplication_PresentationOpenEventHandler(this.PresentationOpen);
}
接下来,在写这个函数。。。
private void PresentationOpen(PowerPoint.Presentation presentation)
{
foreach (PowerPoint.Slide slide in this.Application.ActivePresentation.Slides)
{
foreach (PowerPoint.Shape shape in slide.Shapes)
{
//To see whether the Str_KeyWord exist in the Presentation
string tmp = shape.TextFrame.TextRange.Text;
int i [...]