Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-06-2011, 12:26 AM
Jamal NUMAN Jamal NUMAN is offline Is there a way to capitalize the all the words except the prepositions? Windows XP Is there a way to capitalize the all the words except the prepositions? Office 2007
Expert
Is there a way to capitalize the all the words except the prepositions?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question 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
Attached Images
File Type: jpg Clip_857.jpg (58.3 KB, 12 views)
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #2  
Old 08-06-2011, 03:32 PM
gmaxey gmaxey is offline Is there a way to capitalize the all the words except the prepositions? Windows XP Is there a way to capitalize the all the words except the prepositions? Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 08-06-2011, 11:46 PM
Jamal NUMAN Jamal NUMAN is offline Is there a way to capitalize the all the words except the prepositions? Windows XP Is there a way to capitalize the all the words except the prepositions? Office 2007
Expert
Is there a way to capitalize the all the words except the prepositions?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Thumbs up

Thank you so much gmaxey. it did work

regards

Jamal
Attached Images
File Type: jpg Clip_860.jpg (53.7 KB, 10 views)
File Type: jpg Clip_861.jpg (54.0 KB, 10 views)
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
Reply



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 there a way to capitalize the all the words except the prepositions? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:50 AM.


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