How can I add a usercontrol to a word document?
Hi I am working with a Word Document project using VS2008 Beta 2 and VSTO. All of the documents I am working with are based on a template I created and have a custom ribbon. I can add a usercontrol to a document using the syntax:
Globals.ThisDocument.Controls.AddControl(control, range, width, height, controlName)
If I have multiple Word documents open and want to activate a specific one, I can loop through them using the syntax:
'-
Dim WordAppAs Microsoft.Office.Interop.Word.ApplicationWordApp =
CType(System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"), Word.Application)Dim wordDocAs Word.Document
ForEach wordDocIn WordApp.Documents If wordDoc.Name = desiredDocNameThenwordDoc.Activate()
End
IfNext'-
However, once I activate a document using the above syntax, I cannot add a usercontrol to it because the Word.Document object does not have a controls collection. So If I could add a usercontrol using the syntax
Globals.ThisDocument.Controls.AddControl(control, range, width, height, controlName)
then how could I accomplish the same thing with the wordDoc example above. If this is not possible, is it possible to loop through the open documents a different way? Thanks.

