Need help creating macro regarding auto-capitalize function

P

Patti

I work as a medical transcriptionist and am using Word
2002. I have to type a lot of diagnoses that are numbered
in list style and also a lot of lab values. I have my
Word set to do auto-capitalize, but notice that it will
not capitalize the next sentence following a "colon" or a
number value followed by a period. I have to keep
backspacing in these particular areas and manually
capitalize. I would like to be able to type the entire
report even with the areas that do not auto-cap and use a
macro to check it afterwards.

Can someone tell me how to create a macro where it will
search for the first character following a "colon" and
change that first character to large case and also where
it will search for any "period" followed by two spaces to
check the first character of the next sentence where if
there is small case it will change it to large case.

I am a recent convert from WP5.1 for DOS and knew how to
record macros in that program, but I'm desperately in need
of figuring this macro out for Word as much of my typing
daily has a lot of numbered list areas where it will not
auto-cap, after a colon, or a number value at the end of a
sentence.

It sure would make my life easier if they would make this
an "option" in the future versions of Word where we could
select if we want to have it auto-cap everything or not.

Thanks in advance.

Patti
 
H

Harold Kless[MSFT}

Hi Patti,
Normally in Word when you type a period the next character is Capitalized
unless you are using Soft Returns ( Shift Enter)
This macro will look for a period followed by 2 spaces and then make the
next character upper case.
The second part of the code looks for a colon and capitalizes the next
character.
Sub test()
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
'sets the search text for a period followed by 2 spaces.
With Selection.Find
.Text = ". "
.Wrap = wdFindContinue
End With
'while the find is true move to the next character and make it upper case.
Do While Selection.Find.Execute = True
Selection.MoveRight wdCharacter, 1
Selection.Characters(1).Case = wdUpperCase
Selection.MoveRight wdCharacter, 1


Loop
'search the document for a : and set the next character to upper case.
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = ":"
.Wrap = wdFindContinue
End With

Do While Selection.Find.Execute = True
Selection.MoveRight wdCharacter, 1
Selection.Characters(1).Case = wdUpperCase
Selection.MoveRight wdCharacter, 1


Loop
End Sub

to use this code open the Visual Basic Editor - Click on Tools then Macro
and choose Visual Basic Editor.
On the left pane choose Normal. On the menu bar click on Insert and choose
Module ( Be sure you choose Standard Module and not Class Module).
Paste this code into the module in the Right pane.
Close out of the Visual Basic Editor and return to Word.
Click on Tools Macro and Security - be sure the security level is set to
Medium (recommended but you will be prompted to enable macros when you
start Word ) or low.
Close Word and restart it.
Open a test document and run the macro by clicking on Tools Macro Macros
select "test".
You can add a button to run the macro or assign a Keystroke.


Harold Kless, MCSD
Support Professional
Microsoft Technical Support for Business Applications
(e-mail address removed)

--


This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top