PDA

View Full Version : Solved: Bible study



Pasquale
09-09-2005, 10:47 AM
Hallo, I need help in my bible study.
I must format a text in this form:
1) Where there is a word write all in Capital Letters and bold characters.
Example:
EFREM replace with: <p><b>EFREM</b>
ARNOBIO IL GIOVANE replace with: <p><b>ARNOBIO IL GIOVANE</b>
GREGORIO NISSENO replace with:<p><b>GREGORIO NISSENO</b>

2) At the beginning of all paragraphs -where there are words- I must insert:
<p> (only if you haven't already write it previously completing number one).

Thanks Pasquale:dunno :dunno

Sir Babydum GBE
09-09-2005, 12:26 PM
Let me just get this straight...

You want code to search through a document, find text that is all caps and formatted bold, and if it meets that criteria, then surround it with the symbols you mentioned?

Then, after it's done that, it needs to look at the beginning of each paragraph. And if it didn't already place the symbols mentioned in the first step (i.e. if the paragraph starts without any symbols) then it should place a <p> at the start?

Pasquale
09-09-2005, 12:30 PM
Hi, babydum
You have understund.

pasquale

Sir Babydum GBE
09-09-2005, 12:34 PM
Okay, Pasqual,

This is going to sound strange, but I don't have a clue how to do it. When I read your first post, it took me a while to understand, but now that it has been clarified, hopefully someone on this forum will be able to help.

Good luck.

TonyJollans
09-09-2005, 12:55 PM
Hi Pasquale,

Number 2. This should do it (mind you, I've said that before - LOL) ..

Dim Para As Paragraph
For Each Para In ActiveDocument.Paragraphs
If Len(Para.Range.Text) > 1 Then
If Left(Para.Range.Text, 3) <> "<p>" Then
Para.Range.InsertBefore "<p>"
End If
End If
Next

I'll be back with number 1.

Pasquale
09-09-2005, 01:06 PM
Hi Tony,
it works very well.

thanks
pasquale

TonyJollans
09-09-2005, 01:41 PM
Hi Pasquale,

Back, as promised ... number 1

Selection.HomeKey wdStory

With Selection.Find
.ClearFormatting
.Font.Bold = True
.Text = "<*>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With

While Selection.Find.Execute
If Selection.Text = UCase(Selection.Text) Then
Do
If Selection.End = ActiveDocument.Range.End Then Exit Do
If Not Selection.Next(wdWord, 1).Font.Bold Then Exit Do
If Selection.Next(wdWord, 1).Text <> UCase(Selection.Next(wdWord, 1).Text) Then Exit Do
Selection.MoveEnd wdWord, 1
Loop
Selection.InsertBefore "<p><b>"
Selection.InsertAfter "</b>"
End If
Selection.Collapse wdCollapseEnd
Wend

The HTML tags are sometimes bold, sometimes not - it's quite complex but I doubt you care so I haven't tried to sort it.

Pasquale
09-09-2005, 09:00 PM
Hi Tony,
It works excellent.
I know what are VBA difficult.
I Know that for to realize this. is more complex.
And so i thanks thanks you.
pasquale