Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8373161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:36:41+00:00 2026-06-09T14:36:41+00:00

I am trying to bookmark all the fields with text ‘sample’ in a word

  • 0

I am trying to bookmark all the fields with text ‘sample’ in a word document. I need to bookmark all of them with the bookmark Name “fld_sample”. I am using Microsoft.Office.Interop.Word API to do this programatically. The code below is sample code that I have tried from my end.

using Microsoft.Office.Interop.Word;
using System.Reflection; 

Object oTrue = true; Object oFalse = false;
Application oWord = new Application();
Document oWordDoc = new Document();
oWord.Visible = true;
Object oTemplatePath = @"string Path";

oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref      oMissing);

//selecting the range of text to bookmark.
Range rng = oWordDoc.Range(12, 18);

 oWordDoc.Bookmarks.Add("fld_sample", rng);

 //selecting the next range of text to bookmark with same name
 Range rng1 = oWordDoc.Range(102, 108);

 oWordDoc.Bookmarks.Add("fld_sample", rng1);

But the bookmark is only added for second range of values and not for first range of text.
Can anyone help me with this code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:36:42+00:00Added an answer on June 9, 2026 at 2:36 pm

    Each bookmark needs to have a unique name. Your second call effectively reassigns bookmark ‘fld_sample’. If you want to have a set you can refer to in a loop in code, name subsequent bookmarks something like ‘fld_sample2’, ‘fld_sample3’ etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve the value of all fields in a word document
I am trying to add bookmarks in word document using C# but it doesn't
I am trying to replace bookmark in docx with text in c++\cli using open
I'm trying to add a bookmark from my application using Browser.saveBookmark protected void saveBookmark(String
I'm trying to get the content from all the nodes in the bookmarks menu
I'm trying to create a bookmark extension in Chrome and I want to leverage
Trying to get a wildcard search to pick up on any text in org_name
I am trying to make a bookmark-let. But I'm stuck at a point. I
I'm trying to write a better bookmark manager in Chrome extensions. The problem is
I need some advice on how to go about a particular issue I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.