473,655 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy text between 2 bookmarks

I have two bookmarks,
eg. beginMark and endMark

I need to get the text between these 2 bookmarks, how do I do that?

eg.

<beginMark>
Hello Word!
This is Saturday.
Now is Sunday.
<endMark>
Nov 5 '06 #1
2 3892
I need to get the text between these 2 bookmarks, how do I do that?

Word.Document docActive = applicationObje ct.ActiveDocume nt;
object oFirstBookmark = "FirstBookmark" ;
Word.Range rngFirstBookmar k =
docActive.Bookm arks.get_Item(r ef oFirstBookmark) .Range;
object oSecondBookmark = "SecondBookmark ";
Word.Range rngSecondBookma rk =
docActive.Bookm arks.get_Item(r ef oSecondBookmark ).Range;
object firstBookmarkEn d = rngFirstBookmar k.End;
object secondBookmarkS tart = rngSecondBookma rk.Start;
Word.Range rngTarget =
docActive.Range (ref firstBookmarkEn d, ref secondBookmarkS tart);
string DesiredText = rngTarget.Text;

--
Bill Coan
bi******@wordsi te.com
920-779-9148
"Alan T" <al************ *@yahoo.com.auw rote in message
news:u8******** ******@TK2MSFTN GP04.phx.gbl...
>I have two bookmarks,
eg. beginMark and endMark

I need to get the text between these 2 bookmarks, how do I do that?

eg.

<beginMark>
Hello Word!
This is Saturday.
Now is Sunday.
<endMark>

Nov 5 '06 #2
Thanks.
I have 2 questions about that:
1) I need to put the text or content between 2 bookmarks into a bookmark in
another document.

Word.Range rngTarget = docActive.Range (ref firstBookmarkEn d, ref
secondBookmarkS tart);
object oThirdBookmark = "Bookmark3" ;
Word.Range rngThirdBookmar k = doc3.Bookmarks. get_Item(ref
oThirdBookmark) .Range;
How do I tell to insert the content at that bookmark in my second document ?

2) Do you think Copy and Paste is good ?

"Bill Coan" <bi******@words ite.comwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>I need to get the text between these 2 bookmarks, how do I do that?

Word.Document docActive = applicationObje ct.ActiveDocume nt;
object oFirstBookmark = "FirstBookmark" ;
Word.Range rngFirstBookmar k =
docActive.Bookm arks.get_Item(r ef oFirstBookmark) .Range;
object oSecondBookmark = "SecondBookmark ";
Word.Range rngSecondBookma rk =
docActive.Bookm arks.get_Item(r ef oSecondBookmark ).Range;
object firstBookmarkEn d = rngFirstBookmar k.End;
object secondBookmarkS tart = rngSecondBookma rk.Start;
Word.Range rngTarget =
docActive.Range (ref firstBookmarkEn d, ref secondBookmarkS tart);
string DesiredText = rngTarget.Text;

--
Bill Coan
bi******@wordsi te.com
920-779-9148
"Alan T" <al************ *@yahoo.com.auw rote in message
news:u8******** ******@TK2MSFTN GP04.phx.gbl...
>>I have two bookmarks,
eg. beginMark and endMark

I need to get the text between these 2 bookmarks, how do I do that?

eg.

<beginMark>
Hello Word!
This is Saturday.
Now is Sunday.
<endMark>


Nov 6 '06 #3

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

Similar topics

0
2607
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 the header part of the page (re header/ footer). in that case i get an error saying the bookmark wasn't found/ doesn't exist.
0
1516
by: Javier | last post by:
I have a problem when i try to insert text in a word document.I have bookmarks in the word doc but when intesrt text in a determinate range(i use the range property of word bookmarks) i don't get that the text inserted don't move the rest of the text of the document.I want that the text inserted be inserted in overwrite mode.Sorry the gramatic... I don't want that the lenght of the text inserted move the other text.
2
1530
by: Jay | last post by:
Is there a way to copy text that is always in the same place in a word document, (such as an id number in my case) and then paste it into a text box in another program? I've tried various approaches but none of them seem to work. Thank You
0
1221
by: Mark Hayworth | last post by:
In VB6, you could set bookmarks that were in different files/module/classes/documents. When you clicked the flag tool to go to the next bookmark, it would take you there, regardless if that bookmark was in the same file or not. Now, with VB.Net in VisualStudio.Net, it will only traverse bookmarks in the same file. It won't go to the next file. For example, let's say I have book marks at lines 100 and 200 in frmMain.vb and at line 300...
15
5980
by: Francach | last post by:
Hi, I'm trying to use the Beautiful Soup package to parse through the "bookmarks.html" file which Firefox exports all your bookmarks into. I've been struggling with the documentation trying to figure out how to extract all the urls. Has anybody got a couple of longer examples using Beautiful Soup I could play around with? Thanks, Martin.
0
4075
by: JosAH | last post by:
Greetings, the last two article parts described the design and implementation of the text Processor which spoonfeeds paragraphs of text to the LibraryBuilder. The latter object organizes, cleans up and stores the text being fed to it. Finally the LibrayBuilder is able to produce a Library which is the topic of this part of the article. Introduction
0
4059
by: JosAH | last post by:
Greetings, Introduction At this moment we have a TextProcessor, a LibraryBuilder as well as the Library itself. As you read last week a Library is capable of producing pieces of text in a simple way. We also briefly mentioned the BookMark which represents a single paragraph of text. We haven't seen it's implementation yet. This is the topic of this week's article part.
1
4424
by: JosAH | last post by:
Greetings, Introduction This week we start building Query objects. A query can retrieve portions of text from a Library. I don't want users to build queries by themselves, because users make mistakes. Instead, the Library hands out queries to the user given a simple query String. This is how the library does it:
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8816
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2721
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

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.