Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Jan 2002
    Location
    Israel
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cross links to HTML (Word 2K or XP)

    My programmer friend wants me to convert my document to HTML instead of to PDF. We tried this (Save as Web page) with Word 2000 and Word XP and to our surprise, when we opened the page in IE 5.5, all internal document cross references hyperlinks (Word cross links) except the TOC were lost! Did we do something wrong or is that just the way it is? Does anyone have a macro to change the cross link REF fields to equivalent hyperlink fields, which are migrated to the HTML file? It seems to me that it should be possible since REF fields use hidden bookmarks. Hyperlinks also can use bookmarks. I do not know Word VBA well enough, though.

    Visually it was OK and I really do not care about size since it is for internal use.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Cross links to HTML (Word 2K or XP)

    I'm not sure I understand how you are using REF fields in your document. I use REF fields to essentially copy the contents of a bookmark from one location in a document to another location. This does not behave at all like a hyperlink; in converting this kind of field, I would expect Word to substitute the copied text for the REF field when it converts the document, and lose track of the source.

    Probably you are talking about a different feature that I haven't used. Can you can post a sample document?

  3. #3
    Lounger
    Join Date
    Jan 2002
    Location
    Israel
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cross links to HTML (Word 2K or XP)

    I'm referring (pun intended) to ordinary Word cross links to headings, figure captions, table captions, and so on. They appear as REF fields such as { REF _Ref464205280 h }, which seem to be to be references to hidden bookmarks, created by Word for the occasion. The HTML document created by Word retains the hyperlink references (the reference is hyperlinked if the h switch is included) to ordinary and hidden bookmarks when opened in Word, but does not convert them to HTML hyperlinks and they are not "seen" by a browser. If however, the REF fields are made (manually or otherwise) into Word hyperlink fields to bookmarks or headings, then the converted document retains the jumps even when opened in a browser.

    My problem is how to retain the jumps in the HTML document without manually converting each crosslink field and without spending $4,500 to buy Transit.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Cross links to HTML (Word 2K or XP)

    Something like this?
    <pre>Sub ChngXrefToHlink()
    Dim fld As Field
    For Each fld In ActiveDocument.Fields
    If fld.Type = wdFieldRef Then
    If InStr(1, fld.Code.Text, "REF _", vbBinaryCompare) Then
    fld.Code.Text = Replace(fld.Code, "REF", "HYPERLINK l", _
    , , vbBinaryCompare)
    fld.Code.Text = Replace(fld.Code, "h", vbNullString, _
    , , vbBinaryCompare)
    End If
    End If
    Next
    End Sub</pre>

    This only targets the "virtual" bookmarks, but if that's what you've got, there's your $4,500 macro.

  5. #5
    Lounger
    Join Date
    Jan 2002
    Location
    Israel
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cross links to HTML (Word 2K or XP)

    Super, all I have to do is remove the switches ( r and w ) after running the macro and it works fine. If you could just add a few lines to change the reference to the hyperlink character style it would be perfect!

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Cross links to HTML (Word 2K or XP)

    Where are the r and w and what do those do? You might be able to use another Replace line to get rid of them.

    To apply a character style to the "result" of a hyperlink field, add this inside the inside loop:

    fld.Result.Style = "Hyperlink"

  7. #7
    Lounger
    Join Date
    Jan 2002
    Location
    Israel
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cross links to HTML (Word 2K or XP)

    They are switches in the REF field for crosslinks to headings. I have no idea how they got there. They have no effect (or worse) when used with the HYPERLINK field. They are easily removed with Word's Search and Destroy feature.

    From Word's very own help (that's why it is so easy to understand):
    w Inserts the paragraph number of the bookmarked paragraph in full context from anywhere in the document. For example, when referencing paragraph "ii.," a REF field with the w switch would return "1.a.ii" as a result.

    r Inserts the entire paragraph number of the bookmarked paragraph in relative context

Posting Permissions

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