RE: Repeatedly Change First Letter After [period][blank] to Uppercase
- From: Lene Fredborg <lf@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 9 Feb 2007 00:22:00 -0800
The problem is that you use the range object to find the text (which is
fine), but you apply the changes to the selection and not the range you
found. Therefore, what your macro does is that it changes the characters
found after the selection you had when starting the macro - the number of
characters changed equals the number of ". " found. If you use F8 to step
through the macro, you can see what happens.
You could change the Do-Loop in you macro to the following (note that the
code below also applies uppercase to ". " - but since uppercase and
lowercase of ". " are identical, this is OK).
Do While .Execute = True
With .Parent
Include the next character
.End = .End + 1
'Change to uppercase
.Case = wdUpperCase
'Make sure to move on to next ". "
.Start = .End
End With
Loop
--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
"Don Macnaughton" wrote:
I'm developing a macro in Word 2003 to convert text from point form to.
finished test. One step is supposed to find the string [period][blank] i.e.,
the end of each sentence. Then it's supposed to convert the character
immediately following this string to uppercase because this character will be
the first letter in the next sentence, which therefore should be in
uppercase. Here's what I've been trying to use, which converts a large
number of consecutive characters to uppercase:
With ActiveDocument.Content.Find
.Text = ". "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute = True
With .Parent
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdUpperCase
.Move Unit:=wdSentence, Count:=1
End With
Loop
End With
Thanks for your help.
- Prev by Date: Re: Send document as attachment in Outlook
- Next by Date: Re: how can I create a macro from text I have already typed?
- Previous by thread: Re: Deleting lines
- Next by thread: Re: how can I create a macro from text I have already typed?
- Index(es):
Relevant Pages
|