Problem Source
Q: http://community.csdn.net/Expert/topic/4021/4021389.xml? Temp =. 7616388.
A: steps:
1: Start vs.net Development Environment
2: select the sub-menu item (File/New/Project) under the new menu from the File menu)
3: In the pop-up form, select another project or extended project for the project category
In the template, select the Visual Studio. net external program and select
Name and location, default file name, --> OK
4: Click Next button in the displayed extended wizard form.
5: In the pop-up selection programming language form, select "Use Visual C # To create a program"
Click Next button
6: In the pop-up selection application host form, set Microsoft vsmacros ide
And Microsoft Visual Studio. NET, click Next
7. Enter the name and description of the external program in the displayed input name and description form.
For example, all input values are test data insertion. Click Next button.
8: In the displayed select external program Option form, when you select to load the external program
Fine-tuned. I want my external program to load
. Choose whether to create a user interface for the user to interact with the external program? This
Option click Next button
9: directly click Next button in the Information Form in the pop-up selection help
10: click the button in the pop-up summary form.
11: Open the connect. CS file in the insertstr project and add the following content to it:
Void newline ()
{
(Textselection) applicationobject. activedocument. Selection). newline (1 );
}
Public bool insertstr ()
{
If (applicationobject. activedocument! = NULL)
{
String [] Strout = new string [] {@ "// <summary> ",
@ "// This is a comment generated by an external plug-in ",
@ "// Author: Dengfeng", "// Date: {0 }",
@ "// MSN: SuperCode@hotmail.com ",
@ "// </Summary> "};
Foreach (string STR in Strout)
{
(Textselection) applicationobject. activedocument. Selection). Text = string. Format (STR, system. datetime. Now. tostring ("yyyy-mm-dd "));
Newline ();
}
}
Return true;
}
12: Modify the exec function,
Set handled = true;
Change to handled = insertstr ();
13: compile the project. Right-click the project after compilation is successful,
Select "Install" from the menu to install the plug-in.
14: open a new vs.net IDE, open a text file in it, and in the tool menu
You can see a new menu named myaddin1,
Click it to add text to the current text
Of course, you can extend and modify the inserted content.