Search & Replace
Search and replace text in the current page, section or notebook
Search & Replace
You need Onetastic Add-in
for OneNote to run this macro.
June 20, 2016
Search & Replace
Search & Tag
Search & Select
Search & Replace in Hyperlinks
Search & Highlight
Search & Highlight Language
Search links & add text to label
Show uncompleted to dos
Search & Bold
Search & Spell Check Off
List hyperlinks from search in new page (choose scope)
List hyperlinks from search in new page
See all other macros
Macros by This Author
Insert Monthly Calendar
TOC in Current Notebook
TOC in Current Section
Insert Horizontal Line
Insert Monthly Calendar - Alternative
TOC in Current Page
Search & Replace
Sort Pages By Date
Where am I
Insert Double Horizontal Line
Text to Table
E-mail me if someone replies
Thank you Omer,
I was able to make it work - with the
<Array>QueryText($oParagraph, "Apple", true)</Array>
<Expression>$Text.value = "Orange"</Expression>
Although thats a silly example - I am able to replace real text, so its good for me to learn the basic expressions. Have a great Evening :)
Dan: QueryText returns an Array of Text objects (Array<Text>) not a single Text object. Check the return type on the documentation. So in your code $FindText is an array of text objects and not a single text object because "Apple" may occur multiple times in a paragraph and you will get them all in an array. As a result you can't do $FindText.value, arrays don't have a value property. You can do this instead:
For each $Text in QueryText($Paragraph, "Apple", true)
$Text.value = "Orange"
This will iterate over each text object with value Apple and set their value to Orange.
hope you are great :)
I am trying to find paragraphs that begin with ZZ in that paragraph I would like to replace the word Apple with Plum as an example.
<?xml version="1.0" encoding="utf-16"?>
<Macro name="Search Paragraphs - Containing Text" category="Test Macros" description="" publishDate="00-00-00T00:00:00.000Z" version="13">
<Comment text="Replace in Paragraph that Begins with ZZ" />
<Condition>String_StartsWith($Paragraph.text, "ZZ", true)</Condition>
<Expression>$FindText = QueryText($Paragraph, "Apple", true)</Expression>
<Expression>$FindText.value = "Orange"</Expression>
is this the right way? I have looked at all the docs and examples and cant find a way to make it happen.
Show more comments
ffpc: Currently there is no way to do this. I will add this to my backlog for a future update.
I want to echo Jeremy's question. Is there a way to replace strings with special characters, such as carriage returns?
Tom: This will be fixed in the next update. Thanks for reporting.
The ability to replace a string with nothing would be great, downloaded this macro on 10/15/2016 and the OK button was grayed out until I put a space as the value to replace. Otherwise this is great, thanks!
help，in the old version ，I can replace space with nothing，but it dose not work in the new one,sad face. for example,there are extra spaces between these words ,I want to delete all these spaces，although their should be one space between words, but I don't need any space between two chinese characters.
Hope you can fix this,thanks!
I found macro button in category "Other/Misc" (don't know original title, because I have localized russian version), not in "Search".
Is there a way to find and/or replace special characters or formatting? For example I'd like to find semi-colons and replace them with hard carriage returns. Is that possible with this macro?
Thanks for the help. Love Onetastic!
Fantastic macro, thank you so much. Would you consider adding to it or making an additional one? I am looking for a way to do a search and replace of multiple words. For instance, when inputting from Outlook, email names are come in along with departments due to how our company displays emails. I want to be able to search on multiple phrases (ex. (My group); (Your group);) and replace with a blank or ';'
you've mentioned "slow" twice, but it sounds like you're talking about them in different contexts. are you saying that onetastic has made onenote and your computer actually slow down? i find that very hard to believe if that is the case. it is astonishing light for all that it does.
now as for your work being "slower" do you mean you aren't able to work as efficiently because onetastic is taking up 60% of the main tab? not that it matters, but you must have a very small monitor or are running at a very low resolution. regardless, the solution is very simple: go the very last item in the onetastic section and left-click on "settings" and the first item named "show in a separate tab" will do exactly what you were asking for. the second item under settings might also be handy if you are using a low resolution which is named "compact mode."
it's too bad you're having various slowdowns with using onetastic, since your only using one macro. there are SO MACROS you could be using, let alone the features in onetastic that you would be missing out on by uninstalling. the number of macros should not be slowing down your computer. i hope that helps with getting onetastic in its own tab.
I've been using OneNote for about 2 hours and have noticed that my work is much slower since installing OneTastic because it takes up 60% of the Home tab making the normal items a bit cumbersome to work with. I'm leaving you this note in the idea you might consider passing it to the developer as you'll likely have more clout; I do understand you might disagree.hand
I certainly like having the F & R macros on the Home tab. It just seems more appropriate that OneTastic be on the Add-In tab, since that's what it is. Doing this, at least for me, would make OneNote easier and less cumbersome to work with. I've uninstalled OneTastic for this reason as F&R is something I use occasionally. I definite wish I could keep your macro handy at all times. Thanks again for giving us a very useful macro.
Just installed. Worked fine. Does seem a tiny bit slow though.
Would be great if it automatically copied highlighted text into the search field.
Thanks for a great little utility
amazing Omer. Working perfectly so far
thanks a lot
Hi, can you make the replacement optional,please?
And ability to just find and show me the matches as original OneNote does but in hyperlinks,could be great.
Nino: Can you share the page that has this problem with me to investigate?
There is a dialog box popup when updating the text (the searching process is done without error), giving description as "The XML is invalid". Please check.
Works fine, a very missed feature in OneNote, thanks a lot!
JoBrad, I just published an update that fixes an issue similar to this. Can you please try and see if that solves your problem?
There is a bug with this macro: I have imported lot of notes from Evernote, and they have HTML entity codes in them. If I do a find and replace, the first replace works. Subsequent runs undo the first replacement, however, and only have the last iteration's results. So, if I replace & with &, it will work. Then, if I replace ' with ', the ampersands get replaced with &, and only the apostrophes are corrected.
Hey, I had to restart to onenote for it to work. Thank you so much for this great feature! The only thing I miss now in onenote is to be able to justify text.
Also, can you add an option to search whole words or just partial words?
It did not work at all. I've tried to replace the text, but nothing. I'm using onenote 2010 - 64bits. Portuguese char set.
Daryl, thanks for the report. I can reproduce it and will hopefully fix it in the next update.
Update: this bug occurs whenever there is a container on the page that contains a shape (shapes that have been pasted into containers also containing text). When this is the case the search function still works, but the macro cannot insert text into any containers on the page. I tested this:
1) With a shape (a line) pasted in the same container as the search text - same error as in my post below
2) With a shape (a line) pasted into a container without the search text, and a second container containing search text - same error as in my post below
3) With a shape (a line) pasted outside containers on page with the same containers as in case 2 - search / replace works normally
4) With containers having text only - search / replace works normally
Not sure if there is any way around this, as all of my pages are made from formatted templates that have a container with text and shapes. Any help on this appreciated. I can send examples if the above can't be replicated.
I can't get the search/replace macro to work - for example, after running the macro I briefly see a progress bar and then get the message "12 instances of [text] replaced". After this there is briefly another progress bar and then a message box with header "Error" saying "The ink could not be inserted."
Any ideas why this is happening? I have tried a number of different search strings, the first part of the process always works but the text never actually gets replaced. Seems also to find text with search & highlight but same error and text does not highlight.
I'm using OneNote 2010 x64 on Win7
Mark, this won't replace the URLs of the hyperlinks. It will only work against regular text.
Tried this to replace invalid links after a server name change and it found nothing ??
Terms of Service
Update with many bug fixes and macro improvements
Add Tags with Macros
Resizable Dialog Boxes and Version Info
New Properties, Bug Fixes and Syntax Highlighting for Macros