index > Visual Studio Tools for Office > Word.ControlCollection in an ActionPane

Word.ControlCollection in an ActionPane


Hi,

I'm trying to develop an Action Pane
Marasma
Sorry, I forgot....

Develop Environment VStudio 2005
Language VB
VSTO Version 2005
Marasma
What you are describing should work fine.
Is the document you are adding to protected ? if so you will need to programatically unprotect it.



SaurabhB

Without seeing the code, its hard to determine what the problem is. I have an example of doing this in my book (VSTO for Mere Mortals), but since the book hasn't been published yet, I'll share a bit of the code here for you.

Things to keep in mind are:

  • Rather than using ActiveDocument, you should use ThisDocument, which you can access from the user control by using the Globals class.
  • 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 Class UserControl1

Dim ControlCounter As Integer = 0

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

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

I hope this helps!

Kathleen McGrath
http://blogs.msdn.com/kathleen




This posting is provided "AS IS" with no warranties, and confers no rights.
Kathleen McGrath - MSFT
Great, It works fine!!

Thanks for all
Marasma
reply 5

You can use google to search for other answers

 

More Articles

·Project server error
·Cell.Range catches more than it's supposed to?
·[SOLVED] How to supress message : "the master template will ...
·Getting events when the contents of a Word Range is modified.
·Merging documents in Word
·Unable to retrieve the manifest from the document
·DLL memory problem when called from within Excel
·InnerObject property is not available any more
·Possible Bug in Word 2000/XP add-in implementation when displayin...
·printing workbooks
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

·Setting data source programmatically for¡­
·Adding a node to Word's XML
·VSTO Bookmarks and Undo/Redo
·basic mailmerge function
·Word 2007 customized ribbon deployment
·CircleInvalid and clearcirles
·Excel Addin Password
·Is there version of Dsofile.dll applied ¡­
·VSTO 2005 - Problem loading excel file f¡­
·Problem while try to close Excel File Fr¡­
·Copying RTF into word and from word to a¡­
·Question re the CRM Integration Add-In S¡­
·Wrap VSTO Projects in other Projects?
·Creating a VSTO Class Library project -&¡­
·Web Publish Word Solution

Hot Articles

·API request: WM_INITMENU event
·How To add both SelectionChange and Item¡­
·MS Office 2003 COM Add-Ins not working p¡­
·Refedit Control for VSTO
·Rename print job from Excel
·Shared Add-In
·Running a Word VSTO Project - What steps¡­
·Find and replace for Strings over 255 ch¡­
·BMP for Licensing Add-Ins?
·Trouble to install VSTO
·VSTO Excel designer problem (Visual Stud¡­
·Is it possible? excel named ranges.... s¡­
·Visio and ActionsPane
·Extracting HTML from a MailItem object.
·Migrating VBA Excel solution to VSTO sol¡­

Recommend Articles

·How can i post data from vb.net to word ¡­
·How to display task pane ion Word 2007?
·Binding Keys
·Excel ListObject Problems
·How can I insert and work with images?
·possibly code group error but not sure
·Bookmark Update Problem
·How detect if PIAs Installed?
·Power Point & VSTO
·Replacing text
·SplashScreen in a Word Application
·Using Access in VB.net
·Cutomize File menu in Excel using VSTO 2¡­
·Infopath Automation
·specified cast is not valid error when t¡­