Consulting

Results 1 to 10 of 10

Thread: Solved: Anchor

  1. #1

    Solved: Anchor

    Hallo I need help.
    I have a document where i must put an anchor at every words in bold carachter. The name of anchor is the same bold caracther found.

    My test is:
    AARONITES the descendants of Aaron, and therefore priests. Jehoiada, the father of Benaiah, led 3,700 Aaronites as “fighting men” to the support of David at Hebron (1 Chronicles 12:27). Eleazar (Numbers 3:32), and at a later period Zadok (1 Chronicles 27:17), was their chief. (Easton’s Bible Dictionary)
    ABADDON destruction, the Hebrew name (equivalent to the Greek Apollyon, i.e., destroyer) of “the angel of the bottomless pit” (Revelation 9:11). It is rendered “destruction” in Job 28:22; 31:12; 26:6; Proverbs 15:11; 27:20. In the last three of these passages the Revised Version retains the word “Abaddon.” We may regard this word as a personification of the idea of destruction, or as sheol, the realm of the dead. (Easton’s Bible Dictionary)
    ABAGTHA one of the seven eunuchs in Ahasuerus’s court (Esther 1:10; 2:21). (Easton’s Bible Dictionary)
    ABANA stony (Hebrews marg. “Amanah,” perennial), the chief river of Damascus (2 Kings 5:12). Its modern name is Barada, the Chrysorrhoas, or “golden stream,” of the Greeks. It rises in a cleft of the Anti-Lebanon
    range, about 23 miles north-west of Damascus, and after flowing southward for a little way parts into three smaller streams, the central one flowing through Damascus, and the other two on each side of the city, diffusing beauty and fertility where otherwise there would be barrenness. (Easton’s Bible Dictionary)
    ABARIM regions beyond; i.e., on the east of Jordan, a mountain, or rather a mountain-chain, over against Jericho, to the east and south-east of the Dead Sea, in the land of Moab. From “the top of Pisgah”, i.e., Mount Nebo (q.v.), one of its summits, Moses surveyed the Promised Land (Deuteronomy 3:27; 32:49), and there he died (34:1,5). The Israelites had one of their encampments in the mountains of Abarim (Numbers 33:47,48) after crossing the Arnon. (Easton’s Bible Dictionary)


    The bold caracther are all Blu words and they have always at the beginning of the word the sign
    I must put an anchor with the same bold words how name.


    The anchor saving the file in HTML is <a name=AARONITES>AARONITES</a>
    and so on for every bold words.


    thanks

    pasquale

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Pasquale,
    I'm not that familiar with Anchors. Are you simply requiring the text to be modified as per
    <a name=AARONITES>AARONITES</a> for each blue text?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Hi mdmackillop,
    thanks for the replay.
    <a name=AARONITES>AARONITES</a> must be inserted in HTML code, not to replace the blu txt.
    This is into the file, but not visible into the doc.

    pasquale

    When you open with notepad a doc saved as HTM file the anchor is <a name=AARONITES>AARONITES</a>.
    The txt in the file is always AARONITES, it dosn't change.

    Pasquale

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can you post the text in a Word file. I'm wary of copying and pasting what appear to be bullets.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Thanks,
    I attach a little part of the file.

    pasquale

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Pasquale,
    Still not quite sure if this is what you're after. Let me know.

    [VBA]Sub Macro12()

    With Selection.Find
    .Font.Color = 13828096
    .Text = "*"
    .MatchWildcards = True
    Do While .Execute() = True
    With .Parent
    Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
    txt = Trim(Selection.Text)
    txt = "<a name=" & txt & ">" & txt & "</a>"
    .StartOf Unit:=wdParagraph, Extend:=wdMove
    .InsertAfter txt
    .Move Unit:=wdParagraph, Count:=1
    End With
    Loop
    End With
    End Sub[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Hmmmm.

    Malcolm, you are putting the anchor tag at the beginning of the paragraph. The object here, I believe, is to put the anchor tag around the appropriate target - that is, the bold, blue, words. I have not looked at the file, as I away in the wilds of California, and the person whose computer I am at has it locked down funny. I do not intend to disturb it.

    In any case, ahem...I notice there is no declaration of the variable txt. So of course, since I use Option Explicit, your code failed for me.

    I am just teasing.

    [vba]Dim aWord
    For Each aWord In ActiveDocument.Words
    If aWord.Font.Bold = True And _
    aWord.Font.Color = wdColorLightBlue Then
    aWord.InsertBefore Text:="<a name=" & aWord _
    & ">"
    aWord.InsertAfter Text:="</a>"
    End If
    Next[/vba]will put the tags around every word that is bold and blue. The problem is that it will put the tags in as text.

    AFAIK - but mind you I never use Word to edit HTML - VBA operates in documents, using text. I do not know how to add HTML tags using VBA. That is, ONLY add HTML tags...not text.

    Word is a terrible terrible terrible HTML editor, and any HTML coming from Word (although I can not speak regarding the latest versions) is terrible. Bleeech.

    I am not sure the OP request is possible. To put in the tags (as text)? Sure. See code above. But so that the insertion is ONLY HTML tags....shrug...I don't think so, but I could be wrong.

    You could of course save the the document as .txt, rename it htm, and bring it back. I have not tested this, it seemed a ridiculous process to go through.

    My suggestion? Use a proper HTML editor.

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks Gerry,
    Just trying to assist following instructions. I don't know anything about this HTML coding
    Regards
    Malcolm

    Enjoy your holiday, I'll look after your customers as best I can!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  9. #9
    Thanks mdmackillop and Fumei for replies.

    I change the editor.


    pasquale

  10. #10
    Quote Originally Posted by fumei
    Hmmmm.

    Malcolm, you are putting the anchor tag at the beginning of the paragraph. The object here, I believe, is to put the anchor tag around the appropriate target - that is, the bold, blue, words. I have not looked at the file, as I away in the wilds of California, and the person whose computer I am at has it locked down funny. I do not intend to disturb it.

    In any case, ahem...I notice there is no declaration of the variable txt. So of course, since I use Option Explicit, your code failed for me.

    I am just teasing.

    [vba]Dim aWord
    For Each aWord In ActiveDocument.Words
    If aWord.Font.Bold = True And _
    aWord.Font.Color = wdColorLightBlue Then
    aWord.InsertBefore Text:="<a name=" & aWord _
    & ">"
    aWord.InsertAfter Text:="</a>"
    End If
    Next[/vba]will put the tags around every word that is bold and blue. The problem is that it will put the tags in as text.

    AFAIK - but mind you I never use Word to edit HTML - VBA operates in documents, using text. I do not know how to add HTML tags using VBA. That is, ONLY add HTML tags...not text.
    I have an idea, i Copy the codex html in a new word doc, execute the macro and after I copy the text in the html document.

    I have changed the text replacing Blu carachter with only bold carachter.
    Now my document is in this form:
    <span class=navlevel2><a href="j9_x4rfc.html">abactus</a></span>
    <span class=navlevel2><a href="m32uj31b.html">abacus</a></span>
    <span class=navlevel2><a href="qmurzeya.html">abalienatio</a></span>


    I must insert before bold txt but after .html this txt name="Bold-word">

    The text will become
    <span class=navlevel2><a href="j9_x4rfc.html name="abactus">abactus</a></a></span>
    <span class=navlevel2>><a href="m32uj31b.html name="abacus">abacus</a></a></span>
    <span class=navlevel2><a href="qmurzeya.html name="abalienatio">abalienatio</a></a></span>


    Please how to write the complete macro?? Fumei's VBA codex in your form doesn't works.



    Thanks
    Last edited by Pasquale; 04-22-2007 at 06:04 AM.

Posting Permissions

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