Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Macros : Upper case -> Lower case -> Capitalized case

0.00/5 (No votes)
1 Dec 2003 1  
This macro provides some useful functions for editing : change selection case to Upper case, Lower case, Capitalized case with rotation

Introduction

This is a simple macro but can be quite useful at times.

How to use it

  1. Select some text
  2. Press assigned macro key , change selection case to upper case
  3. Press assigned macro key one more , change upper case to lower case
  4. Press assigned macro key one more, change lower case to capitalized case
  5. Press assigned macro key one more, change capitalized case to upper case

Below this line is the entire flow of the macro

  • Selected case ->
    • Upper case ->
      • Lower case ->
        • Capitalized Case ->
          • Upper Case

Code Listing

Sub MakeCaseUpperLower()
Dim doc
set doc = ActiveDocument 

' Be sure active document is a text document

if doc Is Nothing Then
Exit Sub
elseif doc.Type <> "Text" Then
Exit Sub
End If 

strSelected = doc.Selection
strNewUCase = ""
strNewLCase = ""

strNewUCase = UCase(strSelected)
strNewLCase = LCase(strSelected)
' Upper case -> Lower case

if( strNewUCase = strSelected ) then
doc.Selection = LCase(strSelected)
' Lower case -> Capitalized Case

elseif strNewLCase = strSelected Then
doc.Selection = Left(strNewUCase,1) + Right(strNewLCase, Len(strNewLCase)-1)
' Capitalized Case

else
doc.Selection = strNewUCase
End if
End Sub 

Conclusion

It's some very simple code. Please write your comments. Thank you.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here