Macros to Indicate Colon

D

Designingsally

Hi

I want macro program which can highlight the CAPITAL LETTER immediately
after :(colon).

Ie

When the user types

there are two types of animals: Carnivorous, and Omnivorous.

The macros must highlight C(which is capital) and then a msgbox must appear
with some message.

This process must be sequential( one by one)


Thanks for helping this novice:)


Sally
 
G

Graham Mayor

Try

Dim oRng As Range
With Selection
..HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
MsgBox oRng.Text & " selected"
Selection.Collapse wdCollapseEnd
Loop
End With
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Designingsally

Hi Graham Mayor

Instead of selected the capital letter after : is it possible to highlight
and give a message box with two button Yes and No. When the user clicks Yes,
the capital will change into Small caps. When the user clicks No then it
moves to next sequence. It shd happen sequentially.

I was able to create Yes and No button. But I dont know to give command to
Yes and No and change it from Caps to small letter when the user clicks Yes.

Pls help out.


Thanks in advance.

I modified the code a bit.


Sub Colon()
'
' Colon Macro
Dim oRng As Range
With Selection
..HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
MsgBox oRng.Text & " selected", Buttons:=vbYesNo
Selection.Collapse wdCollapseEnd
Loop
End With
End With

End Sub

--
I believe in Hope.

DesigningSally


Graham Mayor said:
Try

Dim oRng As Range
With Selection
..HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
MsgBox oRng.Text & " selected"
Selection.Collapse wdCollapseEnd
Loop
End With
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Hi

I want macro program which can highlight the CAPITAL LETTER
immediately after :(colon).

Ie

When the user types

there are two types of animals: Carnivorous, and Omnivorous.

The macros must highlight C(which is capital) and then a msgbox must
appear with some message.

This process must be sequential( one by one)


Thanks for helping this novice:)


Sally
 
G

Graham Mayor

OK. Do you want small caps as written or lower case as implied. The
following sets oRng (the capital letter) to lower case.


Dim oRng As Range
Dim sCase As String
With Selection
..HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
sCase = MsgBox(oRng.Text & " selected." & vbCr & _
"Change to lower case?", vbYesNo, "Change Case")
If sCase = vbYes Then oRng.Case = wdLowerCase
Selection.Collapse wdCollapseEnd
Loop
End With
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Hi Graham Mayor

Instead of selected the capital letter after : is it possible to
highlight and give a message box with two button Yes and No. When
the user clicks Yes, the capital will change into Small caps. When
the user clicks No then it moves to next sequence. It shd happen
sequentially.

I was able to create Yes and No button. But I dont know to give
command to Yes and No and change it from Caps to small letter when
the user clicks Yes.

Pls help out.


Thanks in advance.

I modified the code a bit.


Sub Colon()
'
' Colon Macro
Dim oRng As Range
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
MsgBox oRng.Text & " selected", Buttons:=vbYesNo
Selection.Collapse wdCollapseEnd
Loop
End With
End With

End Sub

Try

Dim oRng As Range
With Selection
..HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
MsgBox oRng.Text & " selected"
Selection.Collapse wdCollapseEnd
Loop
End With
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Hi

I want macro program which can highlight the CAPITAL LETTER
immediately after :(colon).

Ie

When the user types

there are two types of animals: Carnivorous, and Omnivorous.

The macros must highlight C(which is capital) and then a msgbox
must appear with some message.

This process must be sequential( one by one)


Thanks for helping this novice:)


Sally
 
D

Designingsally

Thanks :)
It helped me.
--
I believe in Hope.

DesigningSally


Graham Mayor said:
OK. Do you want small caps as written or lower case as implied. The
following sets oRng (the capital letter) to lower case.


Dim oRng As Range
Dim sCase As String
With Selection
..HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
sCase = MsgBox(oRng.Text & " selected." & vbCr & _
"Change to lower case?", vbYesNo, "Change Case")
If sCase = vbYes Then oRng.Case = wdLowerCase
Selection.Collapse wdCollapseEnd
Loop
End With
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Hi Graham Mayor

Instead of selected the capital letter after : is it possible to
highlight and give a message box with two button Yes and No. When
the user clicks Yes, the capital will change into Small caps. When
the user clicks No then it moves to next sequence. It shd happen
sequentially.

I was able to create Yes and No button. But I dont know to give
command to Yes and No and change it from Caps to small letter when
the user clicks Yes.

Pls help out.


Thanks in advance.

I modified the code a bit.


Sub Colon()
'
' Colon Macro
Dim oRng As Range
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
MsgBox oRng.Text & " selected", Buttons:=vbYesNo
Selection.Collapse wdCollapseEnd
Loop
End With
End With

End Sub

Try

Dim oRng As Range
With Selection
..HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set oRng = Selection.Range
oRng.Start = oRng.End - 1
oRng.Select
MsgBox oRng.Text & " selected"
Selection.Collapse wdCollapseEnd
Loop
End With
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Designingsally wrote:
Hi

I want macro program which can highlight the CAPITAL LETTER
immediately after :(colon).

Ie

When the user types

there are two types of animals: Carnivorous, and Omnivorous.

The macros must highlight C(which is capital) and then a msgbox
must appear with some message.

This process must be sequential( one by one)


Thanks for helping this novice:)


Sally
 

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