473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

a question about word automation using dotnet

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
Jul 30 '06 #1
1 2891
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.

bluestar wrote:
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
Jul 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike MacSween | last post by:
Office 2000 From Access I've been starting an instance of word and doing a mail merge. Everything hunky-dory until I applied SP1 yesterday. Now this: dim wrd as Object set wrd =...
2
by: kids | last post by:
Does anybody know any reason which could cause Ms. word automation to crash? I try to call word automation to open a document and use find and replace function. For some reason it works but I...
4
by: Kash | last post by:
Hi everybody: I've developed a web application running on a 2003 server not on the web but on extranet environment of a small Firm (less than 10 users). I've taken benefit of Office Primary...
2
by: Ron | last post by:
Hi there, We have a web application written in C# that need to deal with MS word 2003. it works fine on developer's machine but when I deployed it on web server, we got error msg says "Access is...
1
by: Ron | last post by:
Hi there, We have a web application written in C# that need to deal with MS word 2003. it works fine on developer's machine but when I deployed it on web server, we got error msg says "Access is...
1
by: apondu | last post by:
Hi, can someone help me and provide me the information on how to supress the default action of the shortcut keys of word during word automation. I am using C#.Net I have written a code but...
0
by: venkatesh123 | last post by:
How to specify the formatting styles of the word document in programming(in .net)...can anyone suggest the solution...
0
by: Pramod Elig | last post by:
I developed this code which works fine in my current system which has office 2007, but when I run in word 2000 this doesn’t work. Can you please help me to code word automation using late binding. I...
0
by: hmFG | last post by:
I'm working on a word automation project and having trouble on the format of the inserted text from a rich text box I have successfully replace the field in my template using the following code: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.