Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 25 of 25

Thread: Activedocument.Footnotes.Reference.Text

  1. #21
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi dorogoi,

    Rather than explicitly changing the font colour for each footnote/endnote, you'd do better to modify the Styles. You only need to do that once per document and allows your footnotes and endnotes to acquire the desired attributes via the Style definitions. In that regard, however, I note you've applied the "Endnote Text" Style to both footnotes and endnotes - the former really should use the "Footnote Text" Style.

    I also note that you're explicitly superscripting all footnotes and endnotes. That will mess up any formatting involving the use of superscripting & subscripting in the footnotes and endnotes. Again, if you're after a small font, simply format the Style to suit.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  2. #22

    A little more detail...

    Quote Originally Posted by macropod
    Hi dorogoi,

    Rather than explicitly changing the font colour for each footnote/endnote, you'd do better to modify the Styles. You only need to do that once per document and allows your footnotes and endnotes to acquire the desired attributes via the Style definitions. In that regard, however, I note you've applied the "Endnote Text" Style to both footnotes and endnotes - the former really should use the "Footnote Text" Style.

    I also note that you're explicitly superscripting all footnotes and endnotes. That will mess up any formatting involving the use of superscripting & subscripting in the footnotes and endnotes. Again, if you're after a small font, simply format the Style to suit.
    I see. I wasn't aware I could create a style that would take care of the complexity of my need (superscripted and colored reference mark with the note text in regular "Endnote Text" style.

    Why do you suggest that I should apply footnote style to references that were footnotes? Is it to differentiate each type of note from each other?

    With regards to the superscripting, I'm only superscripting (and coloring) the reference mark, not the text of the note. This is a direct requirement for the program. Without going into ungodly detail, the intention of the program is to prepare a given Word document for importation into another -very- inflexible desktop publishing application (with a name that sounds like it's a very fast subatomic particle). During importation of a Word document, it will convert all foot/endnote reference marks into Roman Numerals without regard for its source. Converting said notes to plain text with this macro prior to importation permits its original numbering scheme to survive unscathed.

  3. #23
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi dorogoi,
    Why do you suggest that I should apply footnote style to references that were footnotes?
    Answer:
    to differentiate each type of note from each other
    Likewise for the reference marks, which use the 'EndNote Reference' and 'FootNote Reference' Styles, respectively. Format those Styles appropriately (they're superscripted by default) and there's no need to mess around with colouring on a per-reference basis.

    Accordingly, your code could be:
    Sub UnLinkNotes()
    'Code by macropod @ http://www.vbaexpress.com/forum/showthread.php?t=31231
    Application.ScreenUpdating = False
    Dim nRng As Range, eNote As Endnote, fNote As Footnote, nRef As String
    With ActiveDocument
      .Styles("Footnote Reference").Font.Color = wdColorGreen
      For Each fNote In .Footnotes
        With fNote
          With .Reference.Characters.First
            .Collapse
            .InsertCrossReference wdRefTypeFootnote, wdFootnoteNumberFormatted, fNote.Index
            nRef = .Characters.First.Fields(1).Result
            .Characters.First.Fields(1).Unlink
          End With
          .Range.Cut
        End With
        Set nRng = .Range
        With nRng
          .InsertAfter vbCr & nRef & " "
          .Paragraphs.Last.Range.Style = "Footnote Text"
          .Paragraphs.Last.Range.Words.First.Style = "Footnote Reference"
          .Start = .End
          .Paste
        End With
      Next
      For Each fNote In .Footnotes
        fNote.Delete
      Next
      .Styles("Endnote Reference").Font.Color = wdColorRed
      For Each eNote In .Endnotes
        With eNote
          With .Reference.Characters.First
            .Collapse
            .InsertCrossReference wdRefTypeEndnote, wdEndnoteNumberFormatted, eNote.Index
            nRef = .Characters.First.Fields(1).Result
            .Characters.First.Fields(1).Unlink
          End With
          .Range.Cut
        End With
        Set nRng = .Range
        With nRng
          .InsertAfter vbCr & nRef & " "
          .Paragraphs.Last.Range.Style = "Endnote Text"
          .Paragraphs.Last.Range.Words.First.Style = "Endnote Reference"
          .Start = .End
          .Paste
        End With
      Next
      For Each eNote In .Endnotes
        eNote.Delete
      Next
    End With
    Set nRng = Nothing
    Application.ScreenUpdating = True
    End Sub
    Last edited by macropod; 04-07-2010 at 10:44 PM.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #24
    macropod,
    First off, thanks a lot for the codes you provided.

    I now have a slightly different problem: a Word 2003 file with each chapter in a separate section and endnotes at the end of each section, numbered from 1 in each.
    The file will be exported to PDF, and I'd like the endnotes to be clickable (just like in your subroutines, just this time the endnotes are at the end of each section).
    Could you please help with some code to achieve this?
    Thank you.

  5. #25
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Nothing in this thread concerns making footnote references or endnote references clickable; indeed the code does just the opposite. Hence your problem is entirely different and you should start a new thread.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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