How to find and replace text of Shape (TextBox) using .NET

Hi, Support,

I have a question like this:
The text in document body can be easily deleted or replaced, however, the deletion/replacement doesn’t apply to the texts in textboxes. Therefore, how to delete or replace text in textboxes?

Thanks for your help.

Ducaisoft

@ducaisoft

Thanks for your inquiry. All text of the document is stored in runs of text. You can use the same approach to delete/replace the text for textbox as you are doing for document’s body. If you still face problem, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

I tried :
TextBox1.Range.Text.Replace(TextBox1.Range.Text, Filename)
the Replace operation doesn’t work.
whereas tried this:
TextBox1.Range.Replace(TextBox1.Range.Text, Filename)
it works.

@ducaisoft

Have your problem solved? If your problem has not solved, please share the requested resources here for testing. Thanks for your cooperation.

Yes! It’s solved by TextBox1.Range.Replace(TextBox1.Range.Text, Filename,FindOptions)