No spaces between En dashes

D

Designingsally

I have a set of words which involve en dashes. My students usually use space
after and before an en dash. I want them NOT to use a space between and after
an en dash. Is there a way how i can automate the process using macros. Using
a message box or comment.
Pls after the - if there is any captalized word. I want the macros to change
to small caps.

for ex: web - learning, corrected form is weblearning. Thanks for the help
in advance.
 
D

DaveLett

Hi,
The example that you provided is most likely a hypen, not an en dash. In the
code below, I've commented out the part that would locate an en dash; you can
restore it if needed:
Dim oRng As Range
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Wrap = wdFindStop
''' .Text = "^="
.Text = "-"
Do While .Execute
Set oRng = Selection.Range
With oRng
.MoveEnd Unit:=wdCharacter, Count:=1
.MoveStart Unit:=wdCharacter, Count:=-1
With .Characters
If .Last = " " Or .First = " " Then
ActiveDocument.Comments.Add _
Range:=oRng, _
Text:="There should be no spaces before or after
hypenated words and en dashes."
End If
End With
End With
Loop
End With

HTH,
Dave
 

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