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

  • SEARCH
  • Home
  • 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 7621839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:17:48+00:00 2026-05-31T04:17:48+00:00

I am working on a word automation project in c# and am using the

  • 0

I am working on a word automation project in c# and am using the interop word library to read/write to word. I am currently using bookmarks in a word template doc to find where to write info to in the word doc from c#. One of my bookmarks consists of two highlighted lines in the doc. Based on a boolean value, i have to decide whether to leave that text there and add a new line of text right after it, or delete those existing two lines from the doc.

So here is my pseudo for it:

if (writeToDoc)
{
// leave selected bookmark text intact and press enter to write another line right after
}
else
{
//delete the selected bookmark text
}

Can anyone please show me how to delete existing text as well as do the equivalent of pressing enter and writing another line from c#?

Thanks

EDIT: Here is the code i have (roughly)

    foreach (var bookmark in wordDoc.Bookmarks)
    {
        var bookMarkNameExistsInCode = listOfBookmarks.Contains(wordDoc.Bookmarks[bookmark].Name);
        if (bookMarkNameExistsInCode )
        {
            object oBookMarkName = wordDoc.Bookmarks[bookmark].Name;
            rng = wordDoc.Bookmarks.get_Item(ref oBookMarkName).Range;
            // at this point i am pointing to the two selected lines labelled as a bookmark in word. How can i deselect and add a new line?
        }
        }
  • 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-05-31T04:17:50+00:00Added an answer on May 31, 2026 at 4:17 am

    If the word manipulation is done on DocX files you could use DocX library and use some very simple commands like text.ReplaceText(); and other very easy/intuitive commands. Replacing Interop with DocX if possible should get you up and running in no time 🙂

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

Sidebar

Related Questions

I am working on a project which uses Word automation through VSTO add-ins and
Using VBA in MS Project 2003 and working with a Word Document I try
Working a on a Google Web Toolkit project. I want to show a word
I am working on a Word 2010 addin for a word template we are
I'm working on a word processor-type app using the WPF RichTextBox. I'm using the
I'm working on a word press project. I noticed that rss is not working
I'm working on a project where I can generate Word documents, one of the
project: Using VB.NET to build a winforms database interface and work-automation app. I am
project: Using VB.NET to build a winforms database interface and work-automation app. I am
I'm working on a Word 2007 template with a macro that will apply character

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.