Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2017, 12:41 PM
seanspotatobusiness seanspotatobusiness is offline Autocorrect numbers followed by any string to have non-breaking space Windows 10 Autocorrect numbers followed by any string to have non-breaking space Office 2016
Competent Performer
Autocorrect numbers followed by any string to have non-breaking space
 
Join Date: Dec 2010
Posts: 101
seanspotatobusiness is on a distinguished road
Default Autocorrect numbers followed by any string to have non-breaking space


Is there a way to set autocorrect so that for every number which is followed by some letters (rather than a period/full-stop), the intervening space is a non-breaking space?

My goal is to stop situations where "7 min" becomes "7
min" because there's not enough space on the line.

Reply With Quote
  #2  
Old 03-08-2017, 01:18 PM
Charles Kenyon Charles Kenyon is offline Autocorrect numbers followed by any string to have non-breaking space Windows 10 Autocorrect numbers followed by any string to have non-breaking space Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Sorry, this is not practical. Autocorrect would treat the following as individual cases:
7
17
27
117
Each would require its own AutoCorrect entry.
In addition, the space is a trigger character and you can't include it at the end of the entry.
If, instead, you just had the numbers, you would end up adding the nonbreaking space before a period or comma as well, since those are also triggers.

Are you aware that Ctrl+Shift+Space = nonbreaking space?

Automated Boilerplate Using Microsoft Word
Reply With Quote
  #3  
Old 03-08-2017, 01:26 PM
Charles Kenyon Charles Kenyon is offline Autocorrect numbers followed by any string to have non-breaking space Windows 10 Autocorrect numbers followed by any string to have non-breaking space Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

You could also do this after-the-fact using wildcard replaces.
Reply With Quote
  #4  
Old 03-08-2017, 01:42 PM
seanspotatobusiness seanspotatobusiness is offline Autocorrect numbers followed by any string to have non-breaking space Windows 10 Autocorrect numbers followed by any string to have non-breaking space Office 2016
Competent Performer
Autocorrect numbers followed by any string to have non-breaking space
 
Join Date: Dec 2010
Posts: 101
seanspotatobusiness is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Are you aware that Ctrl+Shift+Space = nonbreaking space?
Thanks but I already use Ctrl+Shift+Space to do this manually but I won't usually know when this is going to be a problem and I don't want to have to try to form the habit of doing this every single time I write a unit. If I change the margins of the document or make a change to a sentence or paragraph then what was once fine may then require a non-breaking space.

Would it be possible to autocorrect every space before min, hr, sec, g, kg, l, ml, μl etc into a non-breaking space? I only ever use those units when they are preceded by numerical digits.
Reply With Quote
  #5  
Old 03-08-2017, 02:32 PM
Charles Kenyon Charles Kenyon is offline Autocorrect numbers followed by any string to have non-breaking space Windows 10 Autocorrect numbers followed by any string to have non-breaking space Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Unfortunately, not. You cannot have a leading space in an AutoCorrect entry. If you try it for the characters without the space, you will get a space followed by a nonbreaking space followed by the characters.

Again, you could use a replace using wildcards to do this. This could be put into a macro. I do not know how to do it but I know several people frequent this forum who do.

If you are going to use replace, religiously, you could set up the AutoCorrect entries which will give you the space followed by the nonbreaking space and then simply replace for that. Such a replace will not require use of wildcards.

Here is such a macro for that replace:

Code:
Sub Macro1()
'
' Macro1 Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = " ^s"
        .Replacement.Text = "^s"
        .Wrap = wdFindContinue
        .Forward = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
The ^s is for the nonbreaking space.

Last edited by Charles Kenyon; 03-08-2017 at 02:43 PM. Reason: add macro
Reply With Quote
  #6  
Old 03-08-2017, 02:55 PM
seanspotatobusiness seanspotatobusiness is offline Autocorrect numbers followed by any string to have non-breaking space Windows 10 Autocorrect numbers followed by any string to have non-breaking space Office 2016
Competent Performer
Autocorrect numbers followed by any string to have non-breaking space
 
Join Date: Dec 2010
Posts: 101
seanspotatobusiness is on a distinguished road
Default

Thanks. Do you know how to frame my request concisely so I can make a feature request on the Word feedback hub? Is my request adequately expressed by saying

"I would like to be able to use leading spaces in AutoCorrect. The reason is that I want to set up AutoCorrect to change spaces into non-breaking spaces e.g. change "7 hr" into 7 hr"
Reply With Quote
  #7  
Old 03-08-2017, 03:34 PM
macropod's Avatar
macropod macropod is offline Autocorrect numbers followed by any string to have non-breaking space Windows 7 64bit Autocorrect numbers followed by any string to have non-breaking space Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

You could use a fairly simple Find/Replace macro assigned to a keyboard shortcut. For example:
Code:
Sub Demo()
Application.ScreenUpdating = False
With Selection.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "([0-9]) "
    .Replacement.Text = "\1^s"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
Simply select the range to process - if you don't select anything, everything from the insertion point to the end of the document will be processed.

Making an autocorrect option for this would probably cause more problems than it's worth - even you most likely don't want a non-breaking space to replace the ordinary space after every number or even most numbers in a given document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 03-09-2017, 12:12 AM
eNGiNe eNGiNe is offline Autocorrect numbers followed by any string to have non-breaking space Windows 7 32bit Autocorrect numbers followed by any string to have non-breaking space Office 2010 64bit
Expert
 
Join Date: Jan 2012
Location: Brussels [BE]
Posts: 746
eNGiNe is on a distinguished road
Default

If there's some handy way of doing it, how about setting up the autocorrect for the units instead of the numbers?
Reply With Quote
  #9  
Old 03-09-2017, 05:09 AM
Charles Kenyon Charles Kenyon is offline Autocorrect numbers followed by any string to have non-breaking space Windows 10 Autocorrect numbers followed by any string to have non-breaking space Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by eNGiNe View Post
If there's some handy way of doing it, how about setting up the autocorrect for the units instead of the numbers?
See my reply above about that. It won't work. You end up with two spaces, one of which will break at the end of a line. The macro posted by Paul is the best solution. It could be made to run upon save or print.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autocorrect numbers followed by C to °C? seanspotatobusiness Word 8 07-09-2019 02:16 PM
Autocorrect numbers followed by any string to have non-breaking space autocorrect double space to single space frankjake Word 8 09-21-2018 05:44 PM
Autocorrect numbers followed by any string to have non-breaking space Non-breaking space and similar characters gpr Word 2 07-10-2015 06:44 AM
Autocorrect numbers followed by any string to have non-breaking space macro to find a character and insert space so autocorrect will expand redzan Word VBA 3 05-22-2014 04:22 PM
How to extract only numbers from a STRING? Learner7 Excel 3 07-02-2013 06:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:16 PM.


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