Things to remember while designing a VSTO 2005 project.
Programmatic Limitations of Host Controls
l For each host item and host control there is an underlying native Word or Excel object which can be accessed via the InnerObject property of the host item or host control. You cannot however, cast a native object to it’s host item or host control.
l Host items are not created automatically when you create a new document or worksheet at runtime. For example, if you add a Word document at run time, it will be of the type Microsoft.Office.Interop.Word.Document rather than Microsoft.Office.Tools.Word.Document.
l Host controls and Windows Forms controls cannot be added to a native Word document or Excel worksheet, they can only be added to a host item.
l Most methods and properties of host items return the underlying native Office object upon which the item is based
l VSTO does not provide individual collections for each type of host control. For example, it is not possible to enumerate each Microsoft.Office.Tools.Word.Bookmark control in the document using the Microsoft.Office.Interop.Word.Bookmarks collection. You can use the ControlCollection to iterate through all controls (host controls and Windows Forms controls) on the document and then look for items that match the type of host control that you are interested in
l In Microsoft Word, you can pass a host control to a method or property that requires a native Word object for which there is a corresponding host control. However, in Excel, you must pass the native Office object rather than the corresponding host control. You can use the InnerObject property of the host control to pass the native Office object
l If a user deletes or cuts a control from the document at run time, the control cannot be restored by using the Undo or Paste methods. The Undo and Paste operations will add the underlying native Office object back to the document, but the object is no longer a host control.
Managed Windows Forms Controls
l Controls can be added either manually or programmatically
l Controls can be added to a Windows form, the actions pane, or directly on the document.
l Windows Forms controls are not supported inside of a header or footer, or within a subdocument.
The following controls and components are not available in the Toolbox and are not supported for use on documents in VSTO 2005:
Unsupported methods and properties of Word controls
Unsupported methods and properties of Excel controls