I am trying to do in C # (Windows Form application) to print a Word .doc
only by changing some parsions of type @Nome
to a string .
In short, I have a contract and I need to print it. By reporting specific fields, I already have a Word file template and just need to fill it with the data.
I'm doing this:
public void PreencherPorReplace(string CaminhoDocMatriz)
{
//Objeto a ser usado nos parâmetros opcionais
object missing=System.Reflection.Missing.Value;
Word.Application oApp=new Word.Application() ;
object template = CaminhoDocMatriz;
Word.Document oDoc = oApp.Documents.Add(ref template , ref missing,
ref missing, ref missing);
//Troca o conteúdo de alguns tags
Word.Range oRng= oDoc.Range(ref missing ,ref missing );
object FindText = "@Nome";
object ReplaceWith="Teste";
object MatchWholeWord = true;
object Forward = false;
oRng.Find.Execute( ref FindText, ref missing, ref MatchWholeWord,
ref missing, ref missing, ref missing, ref Forward,
ref missing, ref missing, ref ReplaceWith, ref missing,
ref missing, ref missing, ref missing, ref missing);
oApp.Visible = true;
}
But it only replaces @Nome
.