writing into the document (VSTO - C#)

Hi,

how to write into the word document from the task pane's combobox I fill the combobox from database but i can sent the combobox.SelectedItem to cursors positioned point.

Globals.ThisDocument.Paragraphs[1].Range.Text = cmb.SelectedItem.ToString();

this code every time writes top of the document and if there are any word replace over.

please help..
thanks..




Answer this question

writing into the document (VSTO - C#)

  • mvpfp

    Use a Word bookmark and change it's text property ;)



    Globals.ThisDocument.myBookmark.Text = cmb.SelectedItem.ToString();

     



    HTH.

    Bye

  • Aludaan

    Hi Ihsan:

    I would suggest using a Bookmark control to capture the item selected from the combo box.

    I just tried this using a bookmark on the document and a combobox in the actions pane. In this example, the bookmark is called "bookmark1" and the combobox is called "comboBox1". Here is the code:

    Globals.ThisDocument.bookmark1.Text=this.comboBox1.Text.ToString();

    It works very well. :>)  Now, it's important to note that the value of the bookmark will change everytime you select something in the combobox.

    I hope this helps.

    Thanks!
    Mike Hernandez
    Community Program Manager
    VSTO Team


  • writing into the document (VSTO - C#)