Reply
 
Thread Tools Display Modes
  #1   Report Post  
NickEaston
 
Posts: n/a
Default capitalize first letter of all words in selection

I need a macro or something to capitalize the first letter of all words in
selections of several hundred words each.
  #2   Report Post  
garfield-n-odie
 
Posts: n/a
Default

Select the words, and click on Format | Change Case | Title Case | OK.

NickEaston wrote:

I need a macro or something to capitalize the first letter of all words in
selections of several hundred words each.


  #3   Report Post  
Greg Maxey
 
Posts: n/a
Default

Nick,

GNO's method will work for "all" words like you asked. However, here is a
macro that will title case only the words that would normally be in title
case (i.e., excludes words like a, or, etc.). You can exit the "excludes"
to suit your needs:

Sub TitleCaseWithLowerCase()

Application.ScreenUpdating = False

'Capitalize all words in selection
Selection.FormattedText.Case = wdTitleWord

'Uncapitalize the listed words
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

Call DoTitleCase("The ")
Call DoTitleCase("Of ")
Call DoTitleCase("And ")
Call DoTitleCase("Or ")
Call DoTitleCase("But ")
Call DoTitleCase("A ")
Call DoTitleCase("An ")
Call DoTitleCase("To ")
Call DoTitleCase("In ")
Call DoTitleCase("With ")
Call DoTitleCase("From ")
Call DoTitleCase("By ")
Call DoTitleCase("Out ")
Call DoTitleCase("That ")
Call DoTitleCase("This ")
Call DoTitleCase("For ")
Call DoTitleCase("Against ")
Call DoTitleCase("About ")
Call DoTitleCase("Between ")
Call DoTitleCase("Under ")
Call DoTitleCase("On ")
Call DoTitleCase("Up ")
Call DoTitleCase("Into ")

'Uncomment the next line if you want the selection dismissed.
'Selection.Collapse wdCollapseStart

're-capitalize first word in title
Selection.Characters(1).Case = wdUpperCase

End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

NickEaston wrote:
I need a macro or something to capitalize the first letter of all
words in selections of several hundred words each.



  #4   Report Post  
stephanie
 
Posts: n/a
Default

This macro would be very helpful for me. But I am a macro-newbie.
Do you have time to help me?
I opened VB editor, and pasted in everything from Sub titleCaseWith
LowerCase() to End Sub. Closed VB editor.
In Word, selected a passage to convert. Tried to run the macro (selected its
title, and clicked "run").
Got a message: Compile error: Sub or function not defined.
When I click OK, Sub titleCaseWith LowerCase() is yellow highlighted.
What shall I do?
Many thanks.

"Greg Maxey" wrote:

Nick,

GNO's method will work for "all" words like you asked. However, here is a
macro that will title case only the words that would normally be in title
case (i.e., excludes words like a, or, etc.). You can exit the "excludes"
to suit your needs:

Sub TitleCaseWithLowerCase()

Application.ScreenUpdating = False

'Capitalize all words in selection
Selection.FormattedText.Case = wdTitleWord

'Uncapitalize the listed words
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

Call DoTitleCase("The ")
Call DoTitleCase("Of ")
Call DoTitleCase("And ")
Call DoTitleCase("Or ")
Call DoTitleCase("But ")
Call DoTitleCase("A ")
Call DoTitleCase("An ")
Call DoTitleCase("To ")
Call DoTitleCase("In ")
Call DoTitleCase("With ")
Call DoTitleCase("From ")
Call DoTitleCase("By ")
Call DoTitleCase("Out ")
Call DoTitleCase("That ")
Call DoTitleCase("This ")
Call DoTitleCase("For ")
Call DoTitleCase("Against ")
Call DoTitleCase("About ")
Call DoTitleCase("Between ")
Call DoTitleCase("Under ")
Call DoTitleCase("On ")
Call DoTitleCase("Up ")
Call DoTitleCase("Into ")

'Uncomment the next line if you want the selection dismissed.
'Selection.Collapse wdCollapseStart

're-capitalize first word in title
Selection.Characters(1).Case = wdUpperCase

End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

NickEaston wrote:
I need a macro or something to capitalize the first letter of all
words in selections of several hundred words each.




  #5   Report Post  
Greg Maxey
 
Posts: n/a
Default

Stepanie,

One the Tools menu click OptionsEditorAutoSyntax Check.

Try stepping through the code one command at a time using F8. Sometimes the
newsgroups can introduce a "-" in the code which you may need to remove or
the space you have in the macro name.












d, selected a passage to convert. Tried to run the macro
(selected its title, and clicked "run").
Got a message: Compile error: Sub or function not defined.
When I click OK, Sub titleCaseWith LowerCase() is yellow highlighted.
What shall I do?
Many thanks.

"Greg Maxey" wrote:

Nick,

GNO's method will work for "all" words like you asked. However,
here is a macro that will title case only the words that would
normally be in title case (i.e., excludes words like a, or, etc.).
You can exit the "excludes" to suit your needs:

Sub TitleCaseWithLowerCase()

Application.ScreenUpdating = False

'Capitalize all words in selection
Selection.FormattedText.Case = wdTitleWord

'Uncapitalize the listed words
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

Call DoTitleCase("The ")
Call DoTitleCase("Of ")
Call DoTitleCase("And ")
Call DoTitleCase("Or ")
Call DoTitleCase("But ")
Call DoTitleCase("A ")
Call DoTitleCase("An ")
Call DoTitleCase("To ")
Call DoTitleCase("In ")
Call DoTitleCase("With ")
Call DoTitleCase("From ")
Call DoTitleCase("By ")
Call DoTitleCase("Out ")
Call DoTitleCase("That ")
Call DoTitleCase("This ")
Call DoTitleCase("For ")
Call DoTitleCase("Against ")
Call DoTitleCase("About ")
Call DoTitleCase("Between ")
Call DoTitleCase("Under ")
Call DoTitleCase("On ")
Call DoTitleCase("Up ")
Call DoTitleCase("Into ")

'Uncomment the next line if you want the selection dismissed.
'Selection.Collapse wdCollapseStart

're-capitalize first word in title
Selection.Characters(1).Case = wdUpperCase

End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

NickEaston wrote:
I need a macro or something to capitalize the first letter of all
words in selections of several hundred words each.





  #6   Report Post  
stephanie
 
Posts: n/a
Default

Thanks, Greg.

Yes, AutoSyntax is set.
I don't see any hyphens at all in VB.

When I click OK on the Compile Error Message, the message box goes away, and
the first line [Sub TitleCaseWithLowerCase()] is highlighted, with a little
arrow pointing to it. The arrow is in the Left margin.

Pressing F8, Alt-F8, and Cntrl-F8 does nothing.

--I'm working in W2k, with Word 2002. Does that make a difference?

Thanks for helping me with this, Greg. I frequently need this function.


"Greg Maxey" wrote:

Stepanie,

One the Tools menu click OptionsEditorAutoSyntax Check.

Try stepping through the code one command at a time using F8. Sometimes the
newsgroups can introduce a "-" in the code which you may need to remove or
the space you have in the macro name.












d, selected a passage to convert. Tried to run the macro
(selected its title, and clicked "run").
Got a message: Compile error: Sub or function not defined.
When I click OK, Sub titleCaseWith LowerCase() is yellow highlighted.
What shall I do?
Many thanks.

"Greg Maxey" wrote:

Nick,

GNO's method will work for "all" words like you asked. However,
here is a macro that will title case only the words that would
normally be in title case (i.e., excludes words like a, or, etc.).
You can exit the "excludes" to suit your needs:

Sub TitleCaseWithLowerCase()

Application.ScreenUpdating = False

'Capitalize all words in selection
Selection.FormattedText.Case = wdTitleWord

'Uncapitalize the listed words
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

Call DoTitleCase("The ")
Call DoTitleCase("Of ")
Call DoTitleCase("And ")
Call DoTitleCase("Or ")
Call DoTitleCase("But ")
Call DoTitleCase("A ")
Call DoTitleCase("An ")
Call DoTitleCase("To ")
Call DoTitleCase("In ")
Call DoTitleCase("With ")
Call DoTitleCase("From ")
Call DoTitleCase("By ")
Call DoTitleCase("Out ")
Call DoTitleCase("That ")
Call DoTitleCase("This ")
Call DoTitleCase("For ")
Call DoTitleCase("Against ")
Call DoTitleCase("About ")
Call DoTitleCase("Between ")
Call DoTitleCase("Under ")
Call DoTitleCase("On ")
Call DoTitleCase("Up ")
Call DoTitleCase("Into ")

'Uncomment the next line if you want the selection dismissed.
'Selection.Collapse wdCollapseStart

're-capitalize first word in title
Selection.Characters(1).Case = wdUpperCase

End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

NickEaston wrote:
I need a macro or something to capitalize the first letter of all
words in selections of several hundred words each.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting all three letter words in a document how do I do it sol man uk Microsoft Word Help 4 August 2nd 06 04:02 AM
How do I put an accent over a letter? As in Spanish words lsa Microsoft Word Help 1 May 14th 05 07:01 PM
How do I build a word list with number of occurrences of each wor. Bill Crowl Microsoft Word Help 2 March 20th 05 12:17 AM
Word Count mel Microsoft Word Help 2 December 14th 04 11:17 PM
Fix the glitch so words will capitalize after A.(eg) or 12.(eg) me Microsoft Word Help 3 December 6th 04 04:31 PM


All times are GMT +1. The time now is 10:21 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"