Hi,

How can I identify a paragraph that has all word in captial letters in
Microsoft Word.

For example:

ROAD SAFETY SHOW

We had a road safety show and we were walking along the road. Suddenly
we started to dance and we got to know that a new ice cream shop has
opened up.

In the example above, I want to be able to identify "ROAD SAFETY SHOW"
and then have the text formatted as shown below.

#TITLE#ROAD SAFETY SHOW#/TITLE#

We had a road safety show and we were walking along the road. Suddenly
we started to dance and we got to know that a new ice cream shop has
opened up.


Can someone please help me with this?

Thanks,
Yash

RE: Identify Capital Paragraphs with VBA for word. by davelett

davelett
Thu Feb 09 10:44:02 CST 2006

Hi,

You can use something like the following:

Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
With oPara.Range
If .Case = wdUpperCase Then
.Case = wdTitleWord
End If
End With
Next oPara

HTH,
Dave

"itsyash@gmail.com" wrote:

> Hi,
>
> How can I identify a paragraph that has all word in captial letters in
> Microsoft Word.
>
> For example:
>
> ROAD SAFETY SHOW
>
> We had a road safety show and we were walking along the road. Suddenly
> we started to dance and we got to know that a new ice cream shop has
> opened up.
>
> In the example above, I want to be able to identify "ROAD SAFETY SHOW"
> and then have the text formatted as shown below.
>
> #TITLE#ROAD SAFETY SHOW#/TITLE#
>
> We had a road safety show and we were walking along the road. Suddenly
> we started to dance and we got to know that a new ice cream shop has
> opened up.
>
>
> Can someone please help me with this?
>
> Thanks,
> Yash
>
>

Re: Identify Capital Paragraphs with VBA for word. by itsyash

itsyash
Thu Feb 09 10:53:16 CST 2006

Hi Dave,

Thanks for your response. This looks great. I am a novice with Word
VBA. If you dont mind can you help me with the code to add #TITLE#
before the paragraph starts and #/TITLE# after the paragraph ends.

Also can you tell me if there is a way I can identify each line in a
word document.

Thanks in advance,
Yash


RE: Identify Capital Paragraphs with VBA for word. by davelett

davelett
Thu Feb 09 11:22:44 CST 2006

Yes, I can, after all that was in your original post.

Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
With oPara.Range
If .Characters.Count > 1 Then
If .Case = wdUpperCase Then
.Case = wdTitleWord
.InsertBefore "#Title#"
.End = .End - 1
.InsertAfter "#/Title#"
End If
End If
End With
Next oPara

HTH,
Dave


"itsyash@gmail.com" wrote:

> Hi,
>
> How can I identify a paragraph that has all word in captial letters in
> Microsoft Word.
>
> For example:
>
> ROAD SAFETY SHOW
>
> We had a road safety show and we were walking along the road. Suddenly
> we started to dance and we got to know that a new ice cream shop has
> opened up.
>
> In the example above, I want to be able to identify "ROAD SAFETY SHOW"
> and then have the text formatted as shown below.
>
> #TITLE#ROAD SAFETY SHOW#/TITLE#
>
> We had a road safety show and we were walking along the road. Suddenly
> we started to dance and we got to know that a new ice cream shop has
> opened up.
>
>
> Can someone please help me with this?
>
> Thanks,
> Yash
>
>

Re: Identify Capital Paragraphs with VBA for word. by itsyash

itsyash
Thu Feb 09 12:07:26 CST 2006

Hi Dave,

I tried this. I get an error message at the first line saying Compile
Error: User defined type not defined.

Thanks,
Yash


Re: Identify Capital Paragraphs with VBA for word. by itsyash

itsyash
Thu Feb 09 12:11:04 CST 2006

Sorry. I was trying to paste it in Excel VBA

It works great. Awesome

Thanks buddy.