By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

Copy text between 2 bookmarks

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
I need to get the text between these 2 bookmarks, how do I do that?

Word.Document docActive = applicationObject.ActiveDocument;
object oFirstBookmark = "FirstBookmark";
Word.Range rngFirstBookmark =
docActive.Bookmarks.get_Item(ref oFirstBookmark).Range;
object oSecondBookmark = "SecondBookmark";
Word.Range rngSecondBookmark =
docActive.Bookmarks.get_Item(ref oSecondBookmark).Range;
object firstBookmarkEnd = rngFirstBookmark.End;
object secondBookmarkStart = rngSecondBookmark.Start;
Word.Range rngTarget =
docActive.Range(ref firstBookmarkEnd, ref secondBookmarkStart);
string DesiredText = rngTarget.Text;

--
Bill Coan
bi******@wordsite.com
920-779-9148
"Alan T" <al*************@yahoo.com.auwrote in message
news:u8**************@TK2MSFTNGP04.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

P: n/a
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 firstBookmarkEnd, ref
secondBookmarkStart);
object oThirdBookmark = "Bookmark3";
Word.Range rngThirdBookmark = 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******@wordsite.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I need to get the text between these 2 bookmarks, how do I do that?

Word.Document docActive = applicationObject.ActiveDocument;
object oFirstBookmark = "FirstBookmark";
Word.Range rngFirstBookmark =
docActive.Bookmarks.get_Item(ref oFirstBookmark).Range;
object oSecondBookmark = "SecondBookmark";
Word.Range rngSecondBookmark =
docActive.Bookmarks.get_Item(ref oSecondBookmark).Range;
object firstBookmarkEnd = rngFirstBookmark.End;
object secondBookmarkStart = rngSecondBookmark.Start;
Word.Range rngTarget =
docActive.Range(ref firstBookmarkEnd, ref secondBookmarkStart);
string DesiredText = rngTarget.Text;

--
Bill Coan
bi******@wordsite.com
920-779-9148
"Alan T" <al*************@yahoo.com.auwrote in message
news:u8**************@TK2MSFTNGP04.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 discussion thread is closed

Replies have been disabled for this discussion.