![]() |
#1
|
|||
|
|||
![]() 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. ![]() |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
You could also do this after-the-fact using wildcard replaces.
|
#4
|
|||
|
|||
![]()
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. |
#5
|
|||
|
|||
![]()
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 Last edited by Charles Kenyon; 03-08-2017 at 02:43 PM. Reason: add macro |
#6
|
|||
|
|||
![]()
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" |
#7
|
||||
|
||||
![]()
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 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] |
#8
|
|||
|
|||
![]()
If there's some handy way of doing it, how about setting up the autocorrect for the units instead of the numbers?
|
#9
|
|||
|
|||
![]()
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.
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Autocorrect numbers followed by C to °C? | seanspotatobusiness | Word | 8 | 07-09-2019 02:16 PM |
![]() |
frankjake | Word | 8 | 09-21-2018 05:44 PM |
![]() |
gpr | Word | 2 | 07-10-2015 06:44 AM |
![]() |
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 |