Would You like to Share!

Begin to VSTO

by Charlie on May.17, 2008, under VSTO, Hits 684

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, and then click the new project item,you can see the following window.

VSTO in VS2005
Take the PPT as the example.Newly built a“PowerPoint external connection procedure” project.
This will produce a ThisAddIn.cs document.Inside separately by following two function

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
Here cites a simple example. Returns every time when opens documents, to this documents
carries on the key words the search.The code is approximately as follows, the detail question will have the introduction in later.

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);

}
Then, write this function .

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 = tmp.IndexOf(Str_KeyWord);
if (-1 != i )
return true;
}
}

}

 

Thus, our simple search completed.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • TwitThis
  • BlogMemes Jp
  • De.lirio.us
  • blinkbits
  • Slashdot
  • Symbaloo
  • TailRank
  • Webnews.de
  • Reddit
  • Yahoo! Buzz
  • YahooMyWeb
:, ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!