Replacing text in the whole document
See original GitHub issueI’m trying to figure out if there is a way to replace some text in the entire document. So far I managed to successfully use this solution:
string xml = document._document.InnerXml;
document._document.InnerXml = xml.Replace("a", "b");
document.Save(false);
But this does it only in the document part (not in footers & headers). Is there a more “official” way to do this in the library? If not, what would be the day to do it? Thank you!
Issue Analytics
- State:
- Created 7 months ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Find and replace text
Go to Home > Replace. · Enter the word or phrase you want to replace in Find what. · Enter your new text...
Read more >MS Word Replace Text in Document - Activities
I am trying to replace excel data with an MS word placeholder and it fails if the middle name is unavailable. I have...
Read more >Using Find & Replace in Microsoft Word - YouTube
... to quickly replace one word or phrase with another throughout your whole document. You can also use Find and Replace to change...
Read more >How to Find and Replace Text in Word - Nira
Step #3 Select the Replace option located on the top-right-hand side of your screen. Alternatively, you can also press Ctrl + H. The...
Read more >Word: Using Find and Replace
To replace text: · From the Home tab, click the Replace command. · The Find and Replace dialog box will appear. · Type...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes and no. So I would expect someone searching for something like Your company value is 100,000$ and then a user who is actually playing with text formatting formats 10000 with bold and rest of the text with no formatting. And then you have to find 100k and replace it, but only if the full text is Your company value is 100,000$. In this case it would be two WordParagraphs or even more if they play a lot how it’s formatted. It’s a niche thing, but I can see that happening. So just leaving it as something to think about.
I think it’s not worth implementing right now, it’s a very niche thing, and when someone actually needs it, it would be more easy when there are actually real world examples and expectations on how it should behave. For now, the FindAndReplace you implemented is more than enough, for the vast majority of cases, I think 😄