Is there any way in the Font > Capitalise Each Word option to change it so that the likes of and, for, of, etc. are not capitalised along with the rest?
e.g.
International Fund for Agricultural Development
Department of Health and Social Care
Perhaps not and it's just a set thing, but thought I would ask just in case!
TIA,
FP
Capitalise Each Word
-
- 4StarLounger
- Posts: 563
- Joined: 27 Jun 2021, 10:46
Re: Capitalise Each Word
No - but a macro such as the following could work:
Code: Select all
Sub myCapitalise()
Dim mysel As Range
Selection.Range.Case = wdTitleWord
For Each mysel In Selection.Words
If InStr("the in one on at of a for and", LCase(Trim(mysel))) > 0 Then
mysel.Case = wdLowerCase
End If
Next
End Sub
-
- Administrator
- Posts: 78549
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Capitalise Each Word
Word has no built-in way to do this, but see True title case for a macro that you can use.
If you save the code in a module in your default template Normal.dotm, it will always be available. You can assign it to a keyboard shortcut and/or Quick Access Toolbar button for ease of use.
I have attached a demo document with the code - all credit goes to Graham Mayor.
If you save the code in a module in your default template Normal.dotm, it will always be available. You can assign it to a keyboard shortcut and/or Quick Access Toolbar button for ease of use.
I have attached a demo document with the code - all credit goes to Graham Mayor.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 130
- Joined: 12 Aug 2020, 08:40
Re: Capitalise Each Word
I didn't think this was going to be possible! That's really helpful, thank you :)
-
- PlutoniumLounger
- Posts: 15641
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Capitalise Each Word
I have a more complicated version which uses a stored (on disk) reference string:-FrecklePaw wrote: ↑25 Sep 2023, 10:28I didn't think this was going to be possible! That's really helpful, thank you :)
Code: Select all
ProperTitleReference=,a,all,an,and,are,as,can,do,for,from,in,is,it,of,on,or,so,that,the,this,to,up,was,we,with,has,gone,vs,
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.
-
- 4StarLounger
- Posts: 586
- Joined: 14 Nov 2012, 16:06
Re: Capitalise Each Word
Code: Select all
Sub M_snb()
Selection.Range.Case = 0
For Each it In Selection.Words
If Len(Trim(it)) > 3 Then it.Case = 2
Next
End Sub
-
- PlutoniumLounger
- Posts: 15641
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Capitalise Each Word
Hi snb. This is a beautifully concise method. I found that it was a bit too simple for my needs. I needed to fine-tune with a small dictionary.
Of course, a great deal depends on the object. I was in the business of cleaning up documents from a variety of sources. Had I developed that further I would probably have implemented a reference string for each client.
In my example of saving as filenames, I now think that using MSWord's blanket capitalization makes more sense for file names as we tend to want to read file names as a series of distinct strings/words rather than a grammatically correct sentence.
Cheers, Chris
He who plants a seed, plants life.
-
- 4StarLounger
- Posts: 563
- Joined: 27 Jun 2021, 10:46
Re: Capitalise Each Word
Here's my version tweaked to deal with initial capital and colons as per TrueTitleCase (and using the same word list, which can of course be modified)
Code: Select all
Sub myCapitalise()
Dim skipnext As Boolean
Dim mysel As Range
Selection.Range.Case = wdTitleWord
skipnext = True
For Each mysel In Selection.Words
If skipnext Then
skipnext = False
ElseIf InStr("a an and as at but by for if in of on or the to with", LCase(Trim(mysel))) > 0 Then
mysel.Case = wdLowerCase
ElseIf Right(Trim(mysel), 1) = ":" Then
skipnext = True
End If
Next
End Sub
-
- 4StarLounger
- Posts: 586
- Joined: 14 Nov 2012, 16:06
Re: Capitalise Each Word
then I'd prefer:
Code: Select all
Sub M_snb()
For Each it In Selection.Words
it.Case = 2 * (Abs(InStr(" a an and as at but by for if in of on or the to with ", " " & it) = 0))
Next
End Sub