Microsoft Office Tutorials and References
In Depth Information
Adding controls to a document
Let's see a sample program that will add bookmark controls to a Word 2007
document using bookmark host control.
1. Open Visual Studio 2008 to create a new Word 2007 Document
template project.
2. Select New Project . Under Office select 2007 and then select the Word 2007
Document template and name the project.
3. Next, you need to select the document type, and name the document for
your solution.
4. The solution will be created with all of the supporting files for our
development of the Word solution.
5. Write the program to add a bookmark control in Microsoft Office Word 2007,
inside the ThisDocument.cs file.
// Adding bookmark control to document at runtime
private void ThisDocument_Startup(object sender,
System.EventArgs e)
{
// Initializing the Bookmark object
Microsoft.Office.Tools.Word.Bookmark PacktParagraph;
// Add the bookmark range and set the text value
PacktParagraph = this.Controls.AddBookmark(this.
Paragraphs[1].Range, "First Paragraph");
// Add the paragraph text entry
PacktParagraph.Text = "Hello World";
}
Adding controls to a document
Adding controls to a document can be achieved in design mode and also
programmatically. Let's see how to add a control to the document solution
created, at run-time, and in a simple and elegant way.
In this section, we'll add ActiveX to our VSTO Word 2007 document solution.
ActiveX, in case you didn't know, is a component object model developed
by Microsoft for the Windows platform. ActiveX controls are used for
customized applications for gathering data, viewing different kinds of
files, and so on.
 
Search JabSto ::




Custom Search