Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Thu, 4 Sep 2008 16:25:01 -0700,    group: microsoft.public.word.vba.general        back       


Title Case: Uncapitalize articles, short prepositions, etc.   
It would be so simple to improve the Title Case by not capitalizing all the 
"little" words that are, by convention, not usually capitalized in titles, 
such as articles (a, an, the), conjunctions (and, but, nor), and short 
prepositions (in, on, at, to, of, out, with, about, upon, over, under).  
After using Title Case, it is such a pain, and time-consuming, to have to go 
back and uncapitalize these words.  I can't understand why you didn't do this 
YEARS (DECADES?) ago!

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the 
suggestions with the most votes. To vote for this suggestion, click the "I 
Agree" button in the message pane. If you do not see the button, follow this 
link to open the suggestion in the Microsoft Web-based Newsreader and then 
click "I Agree" in the message pane.

http://www.microsoft.com/office/community/en-us/default.mspx?mid=2fc29e3a-278c-41a3-b2fc-b9edee2d423f&dg=microsoft.public.word.vba.general
date: Thu, 4 Sep 2008 16:25:01 -0700   author:   Marcia F. Blackmon Marcia F.

Re: Title Case: Uncapitalize articles, short prepositions, etc.   
This came up recently in another Word forum and I came up with the 
following, which appears to cover most circumstances, though if you can 
think of anything I missed, you can add it to the two arrays following the 
same format:

Sub TrueTitleCase()
Dim sText As Range
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
Dim k As Long
Dim m As Long
Set sText = Selection.Range
'count the characters in the selected string
k = Len(sText)
If k < 1 Then 'If none, then no string is selected
    'so warn the user
    MsgBox "Select the text first!", vbOKOnly, "No text selected"
    Exit Sub 'and quit the macro
End If
'format the selected string as title case
sText.Case = wdTitleWord
'list the exceptions to look for in an array
vFindText = Array("A", "And", "But", "For", "At", _
"As", "The", "Of", "Or", "To", "In")
'list their replacements in a matching array
vReplText = Array("a", "and", "but", "for", "at", _
"as", "the", "of", "or", "to", "in")
With sText
    With .Find
    'replace items in the first list
    'with the corresponding items from the second
        .ClearFormatting
        .Replacement.ClearFormatting
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWholeWord = True
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Format = True
        .MatchCase = True
        For i = LBound(vFindText) To UBound(vFindText)
            .Text = vFindText(i)
            .Replacement.Text = vReplText(i)
            .Execute Replace:=wdReplaceAll
        Next i
    End With
    'Reduce the range of the selected text
    'to encompass only the first character
    .MoveEnd Unit:=wdCharacter, Count:=-Len(sText) + 1
    'format that character as upper case
    .Case = wdUpperCase
    'restore the selected text to its original length
    .MoveEnd Unit:=wdCharacter, Count:=k
    'and check to see if the string contains a colon
    If InStr(1, sText, ":") > 0 Then
        'If it does note the position of the character
        'after the first colon
        m = InStr(1, sText, ":") + 1
        'and set that as the new start of the selected text
        .MoveStart wdCharacter, m
        'set the end of the selected text to include
        'one extra character
        .MoveEnd Unit:=wdCharacter, Count:=-Len(sText) + 1
        'format that character as upper case
        .Case = wdUpperCase
    End If
End With
End Sub

-- 
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Marcia F. Blackmon wrote:
> It would be so simple to improve the Title Case by not capitalizing
> all the "little" words that are, by convention, not usually
> capitalized in titles, such as articles (a, an, the), conjunctions
> (and, but, nor), and short prepositions (in, on, at, to, of, out,
> with, about, upon, over, under). After using Title Case, it is such a
> pain, and time-consuming, to have to go back and uncapitalize these
> words.  I can't understand why you didn't do this YEARS (DECADES?)
> ago!
>
> ----------------
> This post is a suggestion for Microsoft, and Microsoft responds to the
> suggestions with the most votes. To vote for this suggestion, click
> the "I Agree" button in the message pane. If you do not see the
> button, follow this link to open the suggestion in the Microsoft
> Web-based Newsreader and then click "I Agree" in the message pane.
>
> http://www.microsoft.com/office/community/en-us/default.mspx?mid=2fc29e3a-278c-41a3-b2fc-b9edee2d423f&dg=microsoft.public.word.vba.general
date: Sat, 6 Sep 2008 15:22:32 +0300   author:   Graham Mayor

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us