Replacing Text Error - OutOfRange

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?
 
C

Cindy M.

Hi Raphael,
i am using this code but show an error:

the procedure number is out of range (Exception from HRESUL: 0x800706D1

Unfortunately, you don't mention which line of code is causing the error.
I'm also not familiar with this error message in Word. A quick run-
through doesn't show me any obvious syntax errors, so I really have no
idea...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
Top