#1
|
|||
|
|||
Macro to find and replace specific types of spaces
Hello,
This one looks a bit tricky but hope any of you guys know how to do it! I need a Macro to make a multiple search of different types of spaces which appears along to numbers or symbols. The idea is that the Macro FIND some specific types of spaces and THEN replace them with non-breaking spaces. When the Macro finds such spaces, I will decide if the space can be replaced by a non-breaking space or not. So, the Macro should prompt and ask if the space can be replaced by a non-breaking space and then continuing with the rest of instances. Basically, the Macro will search the following spaces: NOTE: I have put an asterisk "*" in order to make visible the space - All numbers following a space: [0‐9]* - Equal sign and space: =* - Space and equal sign: *= - Bracket followed by space: [0‐9]\) Would that be possible? Thanks in advance! |
#2
|
||||
|
||||
If you want to do this interactively as your post suggests, there hardly seems to be any point to using a macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks for letting me know. I assumed that macros may contain interactive content but can see that this is not possible.
So, if we discard the interactive element, can we simply create a macro that finds the spaces mentioned in my post? That is: - numbers following a space: [0‐9]* - Equal sign and space: =* - Space and equal sign: *= - Bracket followed by space: [0‐9]\) Once the macro finds any of these spaces, I will substitute them with non-breaking spaces, if I consider that they are applicable. |
#4
|
||||
|
||||
Quote:
Maybe I'm missing something here - you first asked whether a macro could supply the non-breaking spaces interactively. How is your re-worded requirement any different in that regard?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Quote:
|
#6
|
||||
|
||||
Quote:
Find = [0‐9=\) ^s][ ^s=] will find any of: • 0‐9 • = • ) • a normal space or a non-breaking space followed by a normal space, a non-breaking space, or a =.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Very interesting....
So, what´s the way to add more than one search in the wildcards? Just separating what I want to find in brackets? |
#8
|
||||
|
||||
No, it's just a single search that finds all the possibilities you listed - it may also make what you might regard as false matches. You'd need to test it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find and Replace/Insert 'CR', delete leading Spaces wherever a user Clicks in a Word document | DavidL | Word VBA | 7 | 04-04-2018 12:01 AM |
Find and Replace Macro Need | djpemberton | Word VBA | 2 | 05-04-2016 07:53 PM |
Find and replace mutiple spaces between lowercase words only | Dave T | Word VBA | 2 | 07-16-2015 11:23 PM |
Find and Replace Macro | amparete13 | PowerPoint | 3 | 03-11-2014 05:29 AM |
Macro to replace one specific heading style with another | ubns | Word VBA | 44 | 09-04-2012 08:17 PM |