#1
|
|||
|
|||
Find/replace - symbol for all numbers or symbol letters (Word 97)
Hi,
For a find/replace macro, is there any character that represents all numbers, so that when I run the macro it finds all number instances and doesn't replace the numbers? I want the numbers to stay the same, but I want to replace parts around the numbers, and it'd be very time-consuming to keep making new copies of code to add each number. e.g. page 1 -> page(non-breaking space)2 page 2 -> page(non-breaking space)3 page 3 -> page(non-breaking space)3 etc. paragraph 1 -> page(non-breaking space)2 But there are lots of different words like that that I want to do it for, so without an all numbers character I'd have to do 10 versions of each macro which would take ages. Also, is there a symbol for all letters? I know there are symbols for all numbers and all letters within the find/replace box (e.g. ^$), but they don't seem to work for find/replace which makes me wonder if this is even possible in word 97. Thanks. Last edited by Charles Kenyon; 11-11-2019 at 05:45 AM. Reason: Removed 'macro' from title |
#2
|
||||
|
||||
Search for ^#
Replace with Text before number ^& text after number ^$ finds any letter as you suggest. See also Replace using wildcards
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Thank you! That works well. For ^$, it tells me that ^$ is not a valid character for the replace box, any ideas how I can get around that?
|
#4
|
|||
|
|||
Re-read Graham's answer.
You want ^& in the replace box. That is the symbol for whatever was found. |
#5
|
|||
|
|||
I tried a find/replace:
e.g. find: page_^# Replace: page_^& It adds another "page" word in front, I guess because ^& found the word "page" in the "find" field. Am I doing it wrong? I also tried replacing "^$ ^$" with "^$ ^$" with the aim of removing all double spaces between words (but not between full stops and words), but when I do that it tells me that that ^$ is not a valid character for find/replace. |
#6
|
|||
|
|||
Quote:
Yes, the word "page" is in your found text. Replace: ^& Are you searching for a page number field? |
#7
|
|||
|
|||
I was going to moderate the word "macro" out of the title for this thread but was not sure.
Are you really looking for a macro? I am reading your question as you simply want a solution to be able to do the replace. As you've seen, the general replace function is very powerful. Once you have replace settings that do what you want, you can record a macro if you need one. |
#8
|
|||
|
|||
Quote:
Find: Page ^# Replace: Page_^& Basically with my transcription work we have to add non-breaking spaces after most numbers, but for some numbers (like numbers after the words unit, paragraph, etc.) the non-breaking space goes between the word and the number, not afterwards. I often forget to add them so I'm trying to do find/replaces to find those specific words and add the non-breaking spaces between those words and numbers. But creating 10 sections in a macro for each word + number combination (e.g. page 0-9 / unit 0-9) is time-consuming. Quote:
|
#9
|
|||
|
|||
I am confident that what you want can be done in a single replace.
However, I would start with a replace of: Find text: "Page " Replace text: "Page_" Then a second replace: Find Text: "Page_^#" Replace Text: "^&" (all without the quotation marks) |
#10
|
|||
|
|||
Quote:
So basically I want (as examples): Before: page 1 -> page_1 Before: page 20 -> page_20 But not: page of -> page_of page that -> page_that But i'm not sure how to achieve that easily. |
#11
|
||||
|
||||
You need a wildcard search for that - search for
(page) ([0-9]{1,}) or if 'page' may also include 'Page', search for ([pP]{1}age) ([0-9]{1,}) Replace either with \1^0160\2 Replace using wildcards
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find and Replace Numbers Macro VBA in Microsoft Word | Yotem189 | Word VBA | 3 | 09-20-2018 05:55 AM |
Foot symbol/inches symbol | Mr. P | Word | 1 | 09-05-2016 11:55 AM |
A macro to find a symbol, delete it, and move the cursor to that location | JayBird24 | Word VBA | 1 | 08-19-2016 04:26 PM |
Make my own image and save as symbol in the symbol chart | DeniseN | Office | 1 | 03-20-2015 01:13 AM |
how to find and replace a symbol with another symbol | wondermuse | Word | 5 | 10-09-2014 06:30 AM |