c# Edición de archivo de Word (configuración de campos de elección)

i`m using function below to fill properly data in doc.file by bookmarks and it works good.

public void findAndReplace(Word.Document doc, object bookmark, object replaceWith)
            Word.Range rng = doc.Bookmarks.get_Item(ref bookmark).Range;
            rng.Text = replaceWith.ToString();
            object oRng = rng;
            doc.Bookmarks.Add(bookmark.ToString(), ref oRng);

I`ve got problem with setting values of choice-fields in word file. My questions is, is it even possible to set this kind of data from my c# application ? There is any method to generate Selected or unselected fields like for example in point 21 in link below or only set its value ? http://www.fotosik.pl/pokaz_obrazek/c2409113d79afeba.html

And last question is it possible and reasonable to generate whole report from doc file ?
I`m looking for some solution which helps to generate completely my declaration by c#.

preguntado el 09 de septiembre de 13 a las 21:09

1 Respuestas

Yes that is possible by programmatically adding Content Controls.

This is how you would add a Check Box Content Control:


Microsoft.Office.Tools.Word.ContentControl checkBoxControl1 = 
     this.Controls.AddContentControl("checkBoxControl1", Word.WdContentControlType.wdContentControlCheckBox);

checkBoxControl1.Checked = true;

You can generate entire documents from c#. I would suggest this tutoriales from MSDN about creating templates by using content controls.

Respondido el 10 de Septiembre de 13 a las 01:09

Thank you very much Greg ! It`ll be very helpful - user2762720

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.