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 92199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:08:58+00:00 2026-05-10T23:08:58+00:00

Anyone knows how can I change the text of a Word.Range object but still

  • 0

Anyone knows how can I change the text of a Word.Range object but still keeping it’s format? For example if I have ‘this text‘ and I change it to ‘that txt‘, txt will still be in bold.

I’m looking for a way to change the whole text of the range, not just a single word, as I’m getting the new text from an independent API, I can assume that the new text and the old text have the same number of words.

This is what I got so far:

    for (int i = 0; i < oldWords.Length; i++)     {         if (oldWords[i] == newWords[i])             continue;          object Replace = WdReplace.wdReplaceOne;         object FindText = oldWords[i];         object ReplaceWith = newWords[i];         var success = Sentence.Find.Execute(parameters stub);     }             

But for some reason, it only succeeds in the first Execute, because the range selection remains on the found word.

Edit: got it, after each execute, I had restore the original end position of my Range.

Thanks.

  • 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. 2026-05-10T23:08:59+00:00Added an answer on May 10, 2026 at 11:08 pm

    You can’t use the Execute method to change the text with formatting. You can do it like:

    Range rng=doc.Content; rng.Find.Execute(ref finding, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing)  //if this method returns true, you will get the range at the finding location. if(rng.Find.Found) {   rng.Text='sth';   rng.Bold=0; } 

    Maybe this can help you.

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

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You might consider something with javascript <img src='image.jpg' onerror='this.onerror=null;this.src='default.jpg''> Edit:… May 11, 2026 at 2:12 pm
  • added an answer See MessageQueue on MSDN: Only the following methods are thread… May 11, 2026 at 2:12 pm
  • added an answer Try attaching your Visual Studio to MSIE via Debug >… May 11, 2026 at 2:12 pm

Related Questions

Does anyone know how I can achieve the following effect in OpenGL: Change the
Does anyone know how I can, in platform-independent C++ code prevent an object from
Does anyone know how I can check to see if a directory is writeable
Does anyone know how I can get rid of the following assembler warning? Code
I'm in a curious situation where I previously had no problem achieving what I'm
Question: Does anyone know how to change the current directory of an already running
I have some Javascript which animates a colour change on an HTML element, as
Using an update panel in ASP.NET and with the help of a good tutorial

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.