MS Word macro/shortcut for changing selection to sentence case
Thread poster: Samuel Murray
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 22:35
Member (2006)
English to Afrikaans
+ ...
May 17, 2015

Hello everyone

I have a document in which I have to change several lines to sentence case. These lines typically use a combination of sentence case and title case, but I need them changed to sentence case. What I mean by "sentence case" is that the first letter in my selection is capitalised and the rest of the letters are turned into lowercase (or alternatively, the first letter in a sentence or paragraph is capitalised, and all other letters are turned to lowercase -- both defin
... See more
Hello everyone

I have a document in which I have to change several lines to sentence case. These lines typically use a combination of sentence case and title case, but I need them changed to sentence case. What I mean by "sentence case" is that the first letter in my selection is capitalised and the rest of the letters are turned into lowercase (or alternatively, the first letter in a sentence or paragraph is capitalised, and all other letters are turned to lowercase -- both definitions would suit me). Does anyone know of a macro that does that?

The built-in function of MS Word to change text to "sentence case" only changes the first character in the selection to a capital letter if it is lowercase, and only if the selection includes the entire first word of the sentence or paragraph, and does not affect the rest of the sentence, so... it's a fairly useless feature.

I mean, if I have "the Quick Brown FOX jumps over the Lazy Dog", then I want it changed to "The quick brown fox jumps over the lazy dog". MS Word's built-in function only changes the first "the" to "The" but leaves the rest of the text untouched.

My current solution is to select all text except the first letter, and then toggle the "lowercase" case in MS Word, but that requires two shortcut presses and it requires me to perform this action every time for each line (I may have a dozen consecutive lines that all need that action applied to them).

Got any ideas?

Thanks
Samuel
Collapse


 
Michael Beijer
Michael Beijer  Identity Verified
United Kingdom
Local time: 21:35
Member (2009)
Dutch to English
+ ...
CafeTran shortcut "Change case" May 17, 2015

Hi Samuel,

Probably not much use to you, but I just checked in CafeTran and I can do what you're trying to achieve using the CafeTran shortcut "Change case". Please note that I do need to press it four times to produce the desired output.

The first press converts

the Quick Brown FOX jumps over the Lazy Dog

into:

The Quick Brown FOX jumps over the Lazy Dog

the second press converts the above
... See more
Hi Samuel,

Probably not much use to you, but I just checked in CafeTran and I can do what you're trying to achieve using the CafeTran shortcut "Change case". Please note that I do need to press it four times to produce the desired output.

The first press converts

the Quick Brown FOX jumps over the Lazy Dog

into:

The Quick Brown FOX jumps over the Lazy Dog

the second press converts the above into:

THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG

the third press converts the above into:

the quick brown fox jumps over the lazy dog

and the fourth press turns the above into:

The quick brown fox jumps over the lazy dog

Michael

PS: you said you had "a document", but not what format it is in, and whether you are working in a CAT tool, etc.
Collapse


 
Rossana Triaca
Rossana Triaca  Identity Verified
Uruguay
Local time: 17:35
English to Spanish
AutoHotKey May 18, 2015

I had a macro for this lying around in AHK (it's not unicode though so watch out for special characters, I think Afrikaans uses a couple of those).

It's really easy to tweak too... this is set to use windows key + caps lock, but you can use whatever hotkey you like.

-------------
#CAPSLOCK::

Clip_Save:= ClipboardAll
Clipboard:= ""
Send ^c{delete}
StringLower, Clipboard, Clipboar
... See more
I had a macro for this lying around in AHK (it's not unicode though so watch out for special characters, I think Afrikaans uses a couple of those).

It's really easy to tweak too... this is set to use windows key + caps lock, but you can use whatever hotkey you like.

-------------
#CAPSLOCK::

Clip_Save:= ClipboardAll
Clipboard:= ""
Send ^c{delete}
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "(((^|([.!?]+\s+))[a-z])| i | i')", "$u1")
Send %Clipboard%
Len:= Strlen(Clipboard)
Send +{left %Len%}
Clipboard:= Clip_Save
--------------

Hope it helps!

[Edited at 2015-05-18 04:15 GMT]
Collapse


 
2nl (X)
2nl (X)  Identity Verified
Netherlands
Local time: 22:35
You can use this macro May 18, 2015

You can use this macro:



 
Terry Richards
Terry Richards
France
Local time: 22:35
French to English
+ ...
What's wrong with... May 18, 2015

...this:

Selection.Range.Case = wdLowerCase
Selection.Range.Case = wdTitleSentence

The first line sets the current selection to all lower case and the second sets it to sentence case. I tested it and it works fine for multiple sentences in the selection.


 
wotswot
wotswot  Identity Verified
France
Local time: 22:35
Member (2011)
French to English
Changing Word's Shift-F3 (change case) May 18, 2015

Samuel,

If you're comfortable with VBA, here's how to do it in Word.

In a start-up macro-enabled template (in Normal.dotm, but I recommend writing another one for your own customizations), create a module then paste the following code:

Option Explicit

Public Sub AutoExec()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'NB This only fires if this file is a global template, i.e. in Word's Startup
... See more
Samuel,

If you're comfortable with VBA, here's how to do it in Word.

In a start-up macro-enabled template (in Normal.dotm, but I recommend writing another one for your own customizations), create a module then paste the following code:

Option Explicit

Public Sub AutoExec()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'NB This only fires if this file is a global template, i.e. in Word's Startup folder: in Win7:
'C:\Users\\AppData\Roaming\Microsoft\Word\STARTUP
' THIS Autoexec fires AFTER the one in Normal.dot
'and BEFORE the routines in the 'ThisDocument class module
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
AssignKeyBordShortcut ' Moved to separate Public Sub below
'(to call from Outlook for instance, if Word is set as default editor)
End Sub

Public Sub AssignKeyBordShortcut
'You can use this logic to create/modify any keyboard shortcut
Dim MyKeyCode As Long
Dim MyCommand As String
Application.CustomizationContext = NormalTemplate
MyKeyCode = BuildKeyCode(Arg1:=wdKeyShift, Arg2:=wdKeyF3)
MyCommand = "Check_ShiftF3"
KeyBindings.Add KeyCode:=MyKeyCode, KeyCategory:=wdKeyCategoryMacro, Command:=MyCommand
End Sub

Public Sub Check_ShiftF3()
ConvertCaseWordSel
End Sub

Public Sub ConvertCaseWordSel()
'Press Shift-F3 1, 2, 3 or 4 times
If Selection.Range.Case = 0 Then ' lowercase
Selection.Range.Case = 1 'uppercase
ElseIf Selection.Range.Case = 1 Then 'UPPERCASE
Selection.Range.Case = 2 'Proper Case
ElseIf Selection.Range.Case = 2 Then 'Proper Case
Selection.Range.Case = 4 'Sentence case
Else
Selection.Range.Case = 0 'lowercase
End If
End Sub
Collapse


 
Tina Vonhof (X)
Tina Vonhof (X)
Canada
Local time: 14:35
Dutch to English
+ ...
Two clicks May 18, 2015

Use the Change Case feature in Word. First change the entire selection to lower case and then choose sentence case.

I see that Terry has already suggested this, it seems the simplest way of doing it.




[Edited at 2015-05-18 15:07 GMT]


 
Michael Grant
Michael Grant
Japan
Local time: 05:35
Japanese to English
Try the built-in shortcut: Shift+F3 to change case. May 19, 2015

[NOTE] 1) The Shift+F3 combination works for me, unlike the OP described, so there may be version/settings differences that explain why it doesn't work for him. 2) In further testing, I found that this method does not recognize proper nouns (i.e. company/product names, etc.) so its use cases are limited, to say the least. [/NOTE]

Word (at least Word 2007) has a default keyboard shortcut to change the case of selected text:

Shift+F3

Pressing that key combin
... See more
[NOTE] 1) The Shift+F3 combination works for me, unlike the OP described, so there may be version/settings differences that explain why it doesn't work for him. 2) In further testing, I found that this method does not recognize proper nouns (i.e. company/product names, etc.) so its use cases are limited, to say the least. [/NOTE]

Word (at least Word 2007) has a default keyboard shortcut to change the case of selected text:

Shift+F3

Pressing that key combination will change the case of the text you select text from "ALL CAPS" to "all lowercase" to "Sentence case."

So, if the text you select is originally in all UPPERCASE letters, pressing Shift+F3 once will change it to all lowercase letters, and then pressing Shift+F3 again will change it to sentence case. Pressing it yet again will change it back to all UPPERCASE (i.e. it cycles the text between the three cases).

The cool thing about this is that it is smart enough to respect individual sentences, so if you select an entire paragraph, or indeed, the entire document, this keyboard shortcut will change the individual sentences into sentence case!

What's more, it is even smart enough to treat decimals as decimals, and periods as periods!

Be sure to try it on a copy just in case the results aren't what you expect.

Michael

[Edited at 2015-05-19 00:51 GMT]

[Edited at 2015-05-19 00:55 GMT]

[Edited at 2015-05-19 01:08 GMT]
Collapse


 
Rolf Keller
Rolf Keller
Germany
Local time: 22:35
English to German
Making macros more readable & reliable May 19, 2015

wotswot wrote:

Public Sub ConvertCaseWordSel()
'Press Shift-F3 1, 2, 3 or 4 times


You may use wdLowerCase, wdUpperCase & wdTitleWord instead of the numeric constants.


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 22:35
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
Thanks, everyone May 19, 2015

Michael Beijer wrote:
...and the fourth press turns the above into:
The quick brown fox jumps over the lazy dog


Thanks, but I would rather avoid a solution that requires me to press a shortcut four times for every line of text.

PS: you said you had "a document", but not what format it is in, and whether you are working in a CAT tool, etc.


The title of the post says "MS Word".

Rossana Triaca wrote:
I had a macro for this lying around in AHK (it's not unicode though so watch out for special characters, I think Afrikaans uses a couple of those).


Thanks, that appears like a simple solution.

I haven't tried it, but something tells me that whether it would work would depend on whether one has the "smart paste" feature disabled in MS Word or not. You know, the "feature" (I call it a bug) that inserts a space if you select text from the middle of a word and then cut it.

Terry Richards wrote:
Selection.Range.Case = wdLowerCase
Selection.Range.Case = wdTitleSentence


Aah, thanks for that last line -- I could not figure out what is the VB function for activating what MS Word calls "sentence case".

Tina Vonhof wrote:
Two clicks


Thanks, but I'd rather avoid anything that requires "clicks", because it means I have to move my mouse very carefully to click in the right place, which leads to a condition known as mouse elbow.

Michael Grant wrote:
1) The Shift+F3 combination works for me, unlike the OP described, so there may be version/settings differences that explain why it doesn't work for him.


For this file, I'm using Word 2003, but I expected the shortcut to function similarly in subsequent versions.

Pressing that key combination will change the case of the text you select text from "ALL CAPS" to "all lowercase" to "Sentence case."


In my case, it toggles not between all caps, all lowercase and sentence case, but between all caps, all lowercase and title case. The title case option is sometimes not available with Shift+F3, depending on how MS Word interprets the case of the original text. Either way, my version of MS Word's definition of "sentence case" seems to be "first letter of the first word of a sentence in selected text changed to uppercase" and not "first letter of the first word of a sentence in selected text changed to uppercase and all other letters changed to lowercase".


 
Michael Beijer
Michael Beijer  Identity Verified
United Kingdom
Local time: 21:35
Member (2009)
Dutch to English
+ ...
extra shortcut (four in one) May 19, 2015

Samuel Murray wrote:

Michael Beijer wrote:
...and the fourth press turns the above into:
The quick brown fox jumps over the lazy dog


Thanks, but I would rather avoid a solution that requires me to press a shortcut four times for every line of text.



Yeah, if I had to actually use this myself tons of times in a long document or on a regular basis I'd probably make a quick AutoHotkey (or KnowBrainer 2015 voice command!) shortcut that pressed the shortcut four times in one go.

The cool thing about this CafeTran shortcut is that it cycles through the various case types that you might need, thus combining multiple cases into a single shortcut.

Michael


 
cheetrowe
cheetrowe
English
+ ...
a couple thoughts Jun 26, 2020

Michael Beijer wrote:

Samuel Murray wrote:

Michael Beijer wrote:
...and the fourth press turns the above into:
The quick brown fox jumps over the lazy dog


Thanks, but I would rather avoid a solution that requires me to press a shortcut four times for every line of text.



Yeah, if I had to actually use this myself tons of times in a long document or on a regular basis I'd probably make a quick AutoHotkey (or KnowBrainer 2015 voice command!) shortcut that pressed the shortcut four times in one go.

The cool thing about this CafeTran shortcut is that it cycles through the various case types that you might need, thus combining multiple cases into a single shortcut.

Michael


Although I agree that a keyboard shortcut is great (I simply recorded a macro to change the selection to sentence case and assigned it whatever key I want), I also think that a macro would be quite useful, not so much because I have to hit keys multiple times, but moreso because, when I'm going through hundreds or thousands of lines of references lists and I have to change from title case to sentence case in 30-50% of the lines or whatever, I'd rather that I could go through one by one quickly with a macro. For instance, user hits a key assigned to a macro that selects the next string of text located between two periods that is in title case and then maybe prompt to change to lower case and find next title-case string or hit no to leave as is and find next title-case string. For the OP this might be helpful too. In my case, such a macro would probably do well to ignore initials so that the user doesn't have to skip them all. The search goes on!...


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

MS Word macro/shortcut for changing selection to sentence case






CafeTran Espresso
You've never met a CAT tool this clever!

Translate faster & easier, using a sophisticated CAT tool built by a translator / developer. Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools. Download and start using CafeTran Espresso -- for free

Buy now! »
Wordfast Pro
Translation Memory Software for Any Platform

Exclusive discount for ProZ.com users! Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value

Buy now! »