a question about word automation using dotnet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello
i am trying to develope an application for word automation.i need to insert
header and footer to the document.
i found an exampke in msdn and used it in my application.it works well;but
when i add the code for inserting header;an error apear instead of header in
the document

the error is this:Error! Bookmark not defined.

and this is the piece of code i added for inserting header:

foreach (Word.Section section in oDoc.Sections)
{
object fieldEmpty = Word.WdFieldType.wdFieldEmpty;
object autoText = "HELLO THIS IS HEADER";
object preserveFormatting = true;
//section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text

section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Fields.Add(
section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range,
ref fieldEmpty, ref autoText, ref preserveFormatting);
}


what is this bookmark thing and what should i add to these line in order to
make my code work.
any information is appreciated
bluestar
 
Bluestar,
Cant tell you why it's not working :-(, but i can tell you that
bookmarks in word are used in a similar fashion to bookmarks on HTML
pages - ie they reference a part (or rather the beginning of a part) of
the document.

My guess is that when you insert the header, the text you are inserting
is somehow being mistranslated into one of these bookmark references.

James.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top