R
Raphael Saccomani
Hello all,
i am trying to developer a simple application that replace some words in
microsoft word.
i am using this code but show an error:
the procedure number is out of range (Exception from HRESUL: 0x800706D1
MY CODE:
public void PreencherPorReplace(string CaminhoDocMatriz, Proposta Orcamento)
{
//Objeto a ser usado nos parâmetros opcionais
object missing = System.Reflection.Missing.Value;
//Abre a aplicação Word e faz uma cópia do documento mapeado
Microsoft.Office.Interop.Word.Application oApp = new
Microsoft.Office.Interop.Word.Application();
object template = CaminhoDocMatriz;
Microsoft.Office.Interop.Word.Document oDoc =
oApp.Documents.Add(ref template, ref missing, ref missing, ref missing);
//Troca o conteúdo de alguns tags
Microsoft.Office.Interop.Word.Range oRng = oDoc.Range(ref
missing, ref missing);
object MatchWholeWord = true;
object Forward = false;
#region [PREENCHE OS DADOS DO HEADER]
//Replace da Cidade
object TagCidade = "[CidadeLocal]";
object SubTagCidade = Orcamento.header.CidadeData;
oRng.Find.Execute(ref TagCidade, ref missing, ref
MatchWholeWord, ref missing, ref missing, ref missing, ref Forward,
ref missing, ref missing, ref SubTagCidade, ref missing, ref
missing, ref missing, ref missing, ref missing);
oRng = oDoc.Range(ref missing, ref missing);
#endregion
oApp.Visible = true;
}
i am using:
IDE: VISUAL STUDIO 2008 SP1
OFFICE VERSION: OFFICE 2007
0S: WINDOWS 7 RC
PROG. LANGUAGE: C#
can anybody help me?
i am trying to developer a simple application that replace some words in
microsoft word.
i am using this code but show an error:
the procedure number is out of range (Exception from HRESUL: 0x800706D1
MY CODE:
public void PreencherPorReplace(string CaminhoDocMatriz, Proposta Orcamento)
{
//Objeto a ser usado nos parâmetros opcionais
object missing = System.Reflection.Missing.Value;
//Abre a aplicação Word e faz uma cópia do documento mapeado
Microsoft.Office.Interop.Word.Application oApp = new
Microsoft.Office.Interop.Word.Application();
object template = CaminhoDocMatriz;
Microsoft.Office.Interop.Word.Document oDoc =
oApp.Documents.Add(ref template, ref missing, ref missing, ref missing);
//Troca o conteúdo de alguns tags
Microsoft.Office.Interop.Word.Range oRng = oDoc.Range(ref
missing, ref missing);
object MatchWholeWord = true;
object Forward = false;
#region [PREENCHE OS DADOS DO HEADER]
//Replace da Cidade
object TagCidade = "[CidadeLocal]";
object SubTagCidade = Orcamento.header.CidadeData;
oRng.Find.Execute(ref TagCidade, ref missing, ref
MatchWholeWord, ref missing, ref missing, ref missing, ref Forward,
ref missing, ref missing, ref SubTagCidade, ref missing, ref
missing, ref missing, ref missing, ref missing);
oRng = oDoc.Range(ref missing, ref missing);
#endregion
oApp.Visible = true;
}
i am using:
IDE: VISUAL STUDIO 2008 SP1
OFFICE VERSION: OFFICE 2007
0S: WINDOWS 7 RC
PROG. LANGUAGE: C#
can anybody help me?