#1
|
|||
|
|||
Is there a way to capitalize the all the words except the prepositions?
Is there a way to capitalize the all the words except the prepositions?
please, see the attached image that shows my question i need a command that capitalize the words except the prepositions! is there a way to do this in MS Word rather than the manual way? regards Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#2
|
|||
|
|||
Try this:
Sub RevisedTitleCase() Dim oRng As Range Dim arrFind() As String Dim i As Long Set oRng = Selection.Range If oRng.Words.Count < 1 Then MsgBox "Nothing selected to process. Please select text to process and try again.", vbInformation + vbOKOnly, "Nothing Selected" Exit Sub End If 'Apply title case oRng.Case = wdTitleWord 'list the exceptions to look for in an array arrFind = Split("A|An|And|As|At|But|By|For|If|In|Of|On|Or|Th e|To|With", "|") With oRng With .Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindStop .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Format = True .MatchCase = True For i = LBound(arrFind) To UBound(arrFind) .Text = arrFind(i) .Replacement.Text = LCase(arrFind(i)) .Execute Replace:=wdReplaceAll Next i End With With .Find .Text = ": [A-Za-z]" .MatchWildcards = True While .Execute oRng.Case = wdUpperCase oRng.Collapse wdCollapseEnd Wend End With Selection.Characters(1).Case = wdTitleSentence End With End Sub |
#3
|
|||
|
|||
Thank you so much gmaxey. it did work
regards Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Why Words doesn’t show the style of the selected words automatically???? | Jamal NUMAN | Word | 0 | 04-14-2011 03:20 PM |
is it possibe to capitalize every letter after a "colon space" | angeltread | Word VBA | 4 | 01-17-2011 03:50 PM |
Numbers in Words | janak | Excel | 2 | 12-19-2010 08:53 PM |
How to 'forbid' bad words? | andre20 | Word | 5 | 06-14-2010 08:35 PM |
capitalize first letter of sentences | norco1 | Word | 0 | 06-25-2006 12:37 PM |