473,218 Members | 1,312 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,218 software developers and data experts.

Word Bookmark

How do I make use of the Bookmarks property so that I can write a text
at/below the position of a particular bookmark or the first bookmark ?

private Microsoft.Office.Interop.Word.Document myWordDoc = new Document();

myWordDoc.Bookmarks
Nov 2 '06 #1
2 9463
Alan,

In the following code, applicationObject refers to the Word application. The
code targets the application's ActiveDocument, but you can easily modify
this to target the document referenced by myWordDoc.

The following code inserts some text at a bookmark and then reapplies the
bookmark, in case you need work with the same bookmark later on.

object oBookmarkName = "BookmarkName";
Word.Range rngRange =
applicationObject.ActiveDocument.Bookmarks.get_Ite m(ref
oBookmarkName).Range;
rngRange.Text = "Text to be inserted and bookmarked";
object oRange = rngRange;
applicationObject.ActiveDocument.Bookmarks.Add("Bo okmarkName", ref oRange);

The following code simply inserts some text at a bookmark. In the process,
the bookmark will be deleted, unless it contained no text to start with, in
which case it will still exist but the inserted text will fall after the
bookmark, not within it.

object oAnotherBookmarkName = "AnotherBookmarkName";
applicationObject.ActiveDocument.Bookmarks.get_Ite m(ref
oAnotherBookmarkName).Range.Text = "Text to be inserted";

--
Bill Coan
bi******@wordsite.com
"Alan T" <al*************@yahoo.com.auwrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
How do I make use of the Bookmarks property so that I can write a text
at/below the position of a particular bookmark or the first bookmark ?

private Microsoft.Office.Interop.Word.Document myWordDoc = new Document();

myWordDoc.Bookmarks


Nov 2 '06 #2
Hi Bill,

Thanks for your code.
In your example code they are using the predefined string, however in my
case, I will need to insert the text from the clipboard.

I copied the content of first Word document into clipboard:
WordDoc1.Content.Select();

Then I need to paste the clipboard into my second document:
WordDoc2.Range rngRange =
applicationObject.ActiveDocument.Bookmarks.get_Ite m(ref
oBookmarkName).Range;
rngRange.Text = // <------ here how do I assign the text from clipboard to
this rngRange object ?

"Bill Coan" <bi******@wordsite.comwrote in message
news:e6**************@TK2MSFTNGP04.phx.gbl...
Alan,

In the following code, applicationObject refers to the Word application.
The code targets the application's ActiveDocument, but you can easily
modify this to target the document referenced by myWordDoc.

The following code inserts some text at a bookmark and then reapplies the
bookmark, in case you need work with the same bookmark later on.

object oBookmarkName = "BookmarkName";
Word.Range rngRange =
applicationObject.ActiveDocument.Bookmarks.get_Ite m(ref
oBookmarkName).Range;
rngRange.Text = "Text to be inserted and bookmarked";
object oRange = rngRange;
applicationObject.ActiveDocument.Bookmarks.Add("Bo okmarkName", ref
oRange);

The following code simply inserts some text at a bookmark. In the process,
the bookmark will be deleted, unless it contained no text to start with,
in which case it will still exist but the inserted text will fall after
the bookmark, not within it.

object oAnotherBookmarkName = "AnotherBookmarkName";
applicationObject.ActiveDocument.Bookmarks.get_Ite m(ref
oAnotherBookmarkName).Range.Text = "Text to be inserted";

--
Bill Coan
bi******@wordsite.com
"Alan T" <al*************@yahoo.com.auwrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
>How do I make use of the Bookmarks property so that I can write a text
at/below the position of a particular bookmark or the first bookmark ?

private Microsoft.Office.Interop.Word.Document myWordDoc = new
Document();

myWordDoc.Bookmarks



Nov 5 '06 #3

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

Similar topics

0
by: ingvald | last post by:
hi, i've hit a wall regarding php and ms word. what i want is to open a document containing bookmarks, insert text where the bookmarks are, and save. it's working, unless the bookmark is in...
6
by: Ryan Muller | last post by:
My company just upgraded from Access 97 to Access 2003 today and we are having some issues in a database that generates a Word document from information selected in a form. Here is the code we...
1
by: adam lital | last post by:
Hi, I have word document and i want to replace a specific text with a bookmark using code. Example: in the document i have the text and i want to replace this to a bookmark called ClientName....
0
by: Raj Singh | last post by:
I am facing a problem with Visual C# 2003 and MS Word XP. I am using a customized template for Word and in that template I have defined some bookmarks. I am trying to create a Word document based...
2
by: fordesky | last post by:
Gday, I have a set of Access 2000 tables that I would like to export into a MS Word 2000 template at specific bookmark locations that I've set up. Would anyone know the code to achieve...
1
by: jpr | last post by:
Hello friends, I have a good question for you. I have a form in Access with a check box named chk1. On the same form I have a code that export my data to a template in MS Word. I use bookmark to...
1
by: bluestar | last post by:
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...
2
by: Mike Fellows | last post by:
Hi, I am trying to parse a word document to get a list of all the bookmarks that are setup within the document I need to be able to parse the bookmarks though without knowing the bookmark...
0
by: Alan T | last post by:
My code can select the content of a Word document between 2 bookmarks: if (bookmarks.Exists("first bookmark") & bookmarks.Exists("second bookmark")) { object oFirstBookmark = ("first...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

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.