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
Dave Lett - 09 Feb 2006 16:44 GMT
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
> Hi,
>
[quoted text clipped - 22 lines]
> Thanks,
> Yash
itsyash@gmail.com - 09 Feb 2006 16:53 GMT
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
Dave Lett - 09 Feb 2006 17:22 GMT
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
> Hi,
>
[quoted text clipped - 22 lines]
> Thanks,
> Yash
itsyash@gmail.com - 09 Feb 2006 18:07 GMT
Hi Dave,
I tried this. I get an error message at the first line saying Compile
Error: User defined type not defined.
Thanks,
Yash
itsyash@gmail.com - 09 Feb 2006 18:11 GMT
Sorry. I was trying to paste it in Excel VBA
It works great. Awesome
Thanks buddy.