Click here to Skip to main content
15,881,852 members
Articles / Programming Languages / C++
Article

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

Rate me:
Please Sign up or sign in to vote.
1.46/5 (26 votes)
1 Dec 2003 87.7K   5   15
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

VBScript
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


Written By
Web Developer
Korea (Republic of) Korea (Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralAnother way Pin
melwyn11-Dec-03 0:17
melwyn11-Dec-03 0:17 
QuestionCamelCase? Pin
Jonathan de Halleux3-Dec-03 1:13
Jonathan de Halleux3-Dec-03 1:13 
AnswerRe: CamelCase? Pin
Abin4-Dec-03 13:05
Abin4-Dec-03 13:05 
GeneralOutrageous abuse of the article rating system Pin
Nish Nishant2-Dec-03 19:57
sitebuilderNish Nishant2-Dec-03 19:57 
QuestionWhere's the MACRO??? Pin
WREY2-Dec-03 8:13
WREY2-Dec-03 8:13 
AnswerRe: Where's the MACRO??? Pin
Erik Thompson2-Dec-03 12:01
sitebuilderErik Thompson2-Dec-03 12:01 
They guy has the macro in his article, but since he did not use the <code></code> it looks like article text. The macro is there for use in VC++ to quickly change selection text to different formats.

Cheers,
-Erik
GeneralRe: Where's the MACRO??? Pin
Erik Thompson3-Dec-03 7:24
sitebuilderErik Thompson3-Dec-03 7:24 
GeneralThis is not an article Pin
Jonathan de Halleux2-Dec-03 0:46
Jonathan de Halleux2-Dec-03 0:46 
GeneralRe: No, this is a joke Pin
Jon Newman2-Dec-03 11:58
Jon Newman2-Dec-03 11:58 
GeneralRe: No, this is a joke Pin
Erik Thompson2-Dec-03 12:03
sitebuilderErik Thompson2-Dec-03 12:03 
GeneralRe: No, this is a joke Pin
Nish Nishant2-Dec-03 19:59
sitebuilderNish Nishant2-Dec-03 19:59 
GeneralRe: No, this is a joke Pin
Jon Newman3-Dec-03 2:47
Jon Newman3-Dec-03 2:47 
GeneralRe: No, this is a joke Pin
Nish Nishant4-Dec-03 16:04
sitebuilderNish Nishant4-Dec-03 16:04 
GeneralRe: No, this is a joke Pin
Jon Newman3-Dec-03 2:45
Jon Newman3-Dec-03 2:45 
GeneralRe: No, this is a joke Pin
Erik Thompson3-Dec-03 7:23
sitebuilderErik Thompson3-Dec-03 7:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.