473,517 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2899
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
615
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 = CreateObject("Word.Application")
2
2603
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 don't know why it crash some time.
4
2477
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 Interop Assemblies (PIAs) for automating Word on the server and everything runs smoothly on the server console. The word documents are generated perfectly...
2
1956
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 denied". So i guess the code is OK but web server configuraion has to be changed. I got .Net framework 1.1 installed on webserver and deployed...
1
1938
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 denied". So i guess the code is OK but web server configuraion has to be changed. I got .Net framework 1.1 installed on webserver and deployed...
1
1962
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 it generates a exception "Object Reference not set
0
783
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
1742
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 want to create text, tables. Word.Application WApp = new Word.Application(); // Open Microsoft Word application object objMissing...
0
1098
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: if (fieldName == "background") { myMergeField.Select(); ...
0
7197
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5120
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4786
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1641
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
833
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.