View Single Post
 
Old 06-07-2012, 08:52 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Boatwrench,

Try:
Code:
Sub Test()
Application.ScreenUpdating = False
Dim Fld As Field, FtNtRng As Range, FldRng As Range, i As Long
With ActiveDocument
  For Each Fld In .Fields
    If Fld.Type = wdFieldNoteRef Then
      Set FldRng = Fld.Code
      i = Fld.Result
      While FldRng.Fields.Count = 0
        FldRng.End = FldRng.End + 1
      Wend
      Set FtNtRng = .Footnotes(i).Reference
      If FtNtRng.End > FldRng.End Then
        FldRng.Fields(1).Delete
        FtNtRng.Cut
        FldRng.Paste
        FtNtRng.InsertCrossReference ReferenceType:="Footnote", ReferenceKind:= _
          wdFootnoteNumberFormatted, ReferenceItem:=i, InsertAsHyperlink:=True
        If FldRng.Characters.First = " " Then FldRng.Characters.First = vbNullString
        .Fields.Update
      End If
    End If
  Next
End With
Application.ScreenUpdating = True
End Sub
PS: The above code is for footnotes. For endnotes, use:
Code:
Sub Test()
Application.ScreenUpdating = False
Dim Fld As Field, EndNtRng As Range, FldRng As Range, i As Long
With ActiveDocument
  For Each Fld In .Fields
    If Fld.Type = wdFieldNoteRef Then
      Set FldRng = Fld.Code
      i = Fld.Result
      While FldRng.Fields.Count = 0
        FldRng.End = FldRng.End + 1
      Wend
      Set EndNtRng = .Endnotes(i).Reference
      If EndNtRng.End > FldRng.End Then
        FldRng.Fields(1).Delete
        EndNtRng.Cut
        FldRng.Paste
        EndNtRng.InsertCrossReference ReferenceType:="Endnote", ReferenceKind:= _
          wdEndnoteNumberFormatted, ReferenceItem:=i, InsertAsHyperlink:=True
        If FldRng.Characters.First = " " Then FldRng.Characters.First = vbNullString
        .Fields.Update
      End If
    End If
  Next
End With
Application.ScreenUpdating = True
End Sub
With endnotes, you may have the added complication of section-based vs document-based end noting. The above code assumes the latter.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote