I responded to a question in the VSTO Forum about how to add a TextBox control to a Word document by clicking a button on the ActionsPane. I thought I'd share the code here as well.
This code adds the textbox to the current selection to give the user the opportunity to choose where in the document the textbox is added. Control names must be unique, so I've incremented the name of each control added by counting the total number of controls in the document.
If you have a button on a user control that you add to the actions pane, you can add the following code to the user control:
Public
Dim Selection As Word.Selection = _ Globals.ThisDocument.Application.Selection
Dim ControlName As String = "Control" & _ ControlCounter.ToString()
ControlCounter += 1
Globals.ThisDocument.Controls _ .AddTextBox(Selection.Range, 100, 50, ControlName)
End Sub
End Class
--Kathleen