Consulting

Results 1 to 8 of 8

Thread: Solved: Bible study

  1. #1

    Solved: Bible study

    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

  2. #2
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    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?
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  3. #3
    Hi, babydum
    You have understund.

    pasquale

  4. #4
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location
    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.
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi Pasquale,

    Number 2. This should do it (mind you, I've said that before - LOL) ..
    [VBA]
    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[/VBA]

    I'll be back with number 1.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    Hi Tony,
    it works very well.

    thanks
    pasquale

  7. #7
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi Pasquale,

    Back, as promised ... number 1
    [VBA]
    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[/VBA]

    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.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  8. #8
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •