Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-29-2018, 10:22 AM
dita dita is offline Macro to find and replace specific types of spaces Windows XP Macro to find and replace specific types of spaces Office 2010 64bit
Advanced Beginner
Macro to find and replace specific types of spaces
 
Join Date: Apr 2018
Posts: 34
dita is on a distinguished road
Default 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!
Reply With Quote
  #2  
Old 04-29-2018, 09:22 PM
macropod's Avatar
macropod macropod is offline Macro to find and replace specific types of spaces Windows 7 64bit Macro to find and replace specific types of spaces Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 04-30-2018, 02:32 PM
dita dita is offline Macro to find and replace specific types of spaces Windows XP Macro to find and replace specific types of spaces Office 2010 64bit
Advanced Beginner
Macro to find and replace specific types of spaces
 
Join Date: Apr 2018
Posts: 34
dita is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 04-30-2018, 02:41 PM
macropod's Avatar
macropod macropod is offline Macro to find and replace specific types of spaces Windows 7 64bit Macro to find and replace specific types of spaces Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by dita View Post
I assumed that macros may contain interactive content but can see that this is not possible.
They can contain interactive content but, for what you described, that makes such a macro fairly pointless, since it's going to have to pause at each match and wait for user input, just as it would when using Find/Replace.
Quote:
Originally Posted by dita View Post
So, if we discard the interactive element, can we simply create a macro that finds the spaces mentioned in my post?
...
Once the macro finds any of these spaces, I will substitute them with non-breaking spaces, if I consider that they are applicable.
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]
Reply With Quote
  #5  
Old 05-05-2018, 03:27 AM
Pintus Pintus is offline Macro to find and replace specific types of spaces Windows XP Macro to find and replace specific types of spaces Office 2010 64bit
Novice
 
Join Date: May 2018
Posts: 7
Pintus is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
They can contain interactive content but, for what you described, that makes such a macro fairly pointless, since it's going to have to pause at each match and wait for user input, just as it would when using Find/Replace.

Yes, I don´t mind if the macro do a pause at each match and wait for my input. The reason why I want to do this with a macro is because searching with Wildcards only allows to find one item per Find/Replace. So, using a macro, we could find different type of spaces in one go.

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?
If the macro can do the search interactively that would be best option but I´m not sure if this possible or not.
Reply With Quote
  #6  
Old 05-05-2018, 03:56 AM
macropod's Avatar
macropod macropod is offline Macro to find and replace specific types of spaces Windows 7 64bit Macro to find and replace specific types of spaces Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Pintus View Post
searching with Wildcards only allows to find one item per Find/Replace
Not so. For example,
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]
Reply With Quote
  #7  
Old 05-05-2018, 08:36 AM
Pintus Pintus is offline Macro to find and replace specific types of spaces Windows XP Macro to find and replace specific types of spaces Office 2010 64bit
Novice
 
Join Date: May 2018
Posts: 7
Pintus is on a distinguished road
Default

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?
Reply With Quote
  #8  
Old 05-06-2018, 12:47 AM
macropod's Avatar
macropod macropod is offline Macro to find and replace specific types of spaces Windows 7 64bit Macro to find and replace specific types of spaces Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Pintus View Post
So, what´s the way to add more than one search in the wildcards?

Just separating what I want to find in brackets?
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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find and replace specific types of spaces 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
Macro to find and replace specific types of spaces Find and replace mutiple spaces between lowercase words only Dave T Word VBA 2 07-16-2015 11:23 PM
Macro to find and replace specific types of spaces Find and Replace Macro amparete13 PowerPoint 3 03-11-2014 05:29 AM
Macro to find and replace specific types of spaces Macro to replace one specific heading style with another ubns Word VBA 44 09-04-2012 08:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft