Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Identify Capital Paragraphs with VBA for word.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
itsyash@gmail.com - 09 Feb 2006 16:13 GMT
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.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.