Is there any way to convert a document in one word upper and one lower case sequentially? For example, I write a line "HOW ARE YOU I AM FINE" and this will convert into "HoW aRe YoU i Am FiNe".
2 Answers
Here's a VBA routine that will do what you describe:
Sub Alternate_case()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^$"
.Forward = True
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While True
.Execute Wrap:=wdFindStop
If Not .Found Then Exit Do
Selection.Range.Case = wdUpperCase
.Execute Wrap:=wdFindStop
If Not .Found Then Exit Do
Selection.Range.Case = wdLowerCase
Loop
End With
End Sub
The Selection.HomeKey statement is equivalent
to Ctrl+Home;
it jumps to the beginning of the document.
Delete it if you just want to start wherever you are
when you invoke the routine.
The next dozen lines set up a case-insensitive, non-wildcarded,
forward search for a letter (Text = "^$").
(You may be able to get away with deleting the ….ClearFormatting lines
and the … = False lines,
as these just explicitly establish the default parameters.)
The Do While True block is an "infinite loop"
that stops after it finds the last letter in the document.
It executes the configured search (for a letter)
without wraparound to the beginning of the document (Wrap:=wdFindStop);
if it fails (Not .Found), it terminates the loop (Exit Do),
otherwise it proceeds to capitalize the selected letter and search again.
On the next search, if successful, it sets the letter to lower case,
and so on.
See How do I add VBA in MS Office? for general information on how to use VBA in Microsoft Word (and Excel, etc.)
This is indeed nearly possible. Just select the option you want using the capitlization font button.
Here is a full description of what you must do.
On the Home tab, in the Font group, click Change Case
, and then click the capitalization option that you want.
You can also select text then perform the keyboard shortcut
To change case by using a keyboard shortcut, press SHIFT+F3 until the style you want — title case, all caps, or lowercase — is selected.
Which is exactly what you should do to your question. You can even copy and paste the quoted text to do exactly that.
Hey guys i have a question that is there any way to convert a document in one word upper and one lower case sequentially for example i write a line "how are you i am fine" and this will convert into "HoW aRe YoU i Am FiNe"
- 44,080

