Microsoft Office Forums Repair two interspersed endnote numbering schemes?

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-11-2013, 10:47 AM
gidmeister gidmeister is offline Repair two interspersed endnote numbering schemes? Windows 7 64bit Repair two interspersed endnote numbering schemes? Office 2007
Novice
Repair two interspersed endnote numbering schemes?
 
Join Date: Apr 2013
Posts: 4
gidmeister is on a distinguished road
Default Repair two interspersed endnote numbering schemes?

My mother, who is not computer savvy, revised a Word document using the "track changes" option. She had many end notes, and she moved paragraphs around that referred to end-notes, she also added new end-notes, sometimes she deleted the end-notes in a way that I find questionable - she went to the end-note and hit the delete key until all the letters were red. She also ran into problems where the entire end-note would be formatted as a superscript, or subscript, and she tried to correct those. Anyway, I made a copy of the document, I implemented "accept all changes" and then she worked on it, until she suddenly noticed that the end-note numbering was wrong. She would have end-note numbering such as 34, 35, 36, and all of a sudden 1,2,3. and then 37,38,39 In fact, there are two end-notes with the same number '4', for instance. I can't find any way to renumber it. She says that the end-note that starts with one (after the 36) was simply a new note that she added.


If anyone knows how to clean up this mess, I'd appreciate hearing from you.
Reply With Quote
  #2  
Old 04-11-2013, 05:26 PM
macropod's Avatar
macropod macropod is offline Repair two interspersed endnote numbering schemes? Windows 7 64bit Repair two interspersed endnote numbering schemes? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,533
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Cross-posted at: http://social.msdn.microsoft.com/For...7-15d2ebae4318
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

Without seeing the document, it's hard to be sure what the issue is. Can you attach a document to a post with some representative content (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 04-12-2013, 03:25 AM
gidmeister gidmeister is offline Repair two interspersed endnote numbering schemes? Windows 7 64bit Repair two interspersed endnote numbering schemes? Office 2007
Novice
Repair two interspersed endnote numbering schemes?
 
Join Date: Apr 2013
Posts: 4
gidmeister is on a distinguished road
Default Here is the attachment. Thanks.

Here is a page I lifted out of the manuscript. It has one end-note from the original set (number 25) and all the others are from the new set.

I notice that when I click the icon on the home tab that shows all format marks that one set of footnote numbers has squares around them.

Last edited by macropod; 04-14-2013 at 06:31 AM. Reason: Attachment deleted for privacy
Reply With Quote
  #4  
Old 04-12-2013, 07:22 AM
macropod's Avatar
macropod macropod is offline Repair two interspersed endnote numbering schemes? Windows 7 64bit Repair two interspersed endnote numbering schemes? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,533
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Based on what your attachment contained, the following macro should repair the document.
Code:
Option Explicit
 
Sub RepairEndNotes()
Application.ScreenUpdating = False
Dim Rng As Range, NtRng As Range, RngNt As Range
Dim i As Long, j As Long, eNote As Endnote
With ActiveDocument
  .Styles("Endnote Text").ParagraphFormat.SpaceAfter = 6
  Set Rng = .Range.Characters.Last
  For Each eNote In .Endnotes
    i = i + 1
    StatusBar = "Extracting Endnote: " & i
    With eNote
      Set NtRng = .Reference.Characters.First
      NtRng.End = .Reference.End
      With NtRng
        Do While .Characters.Last.Next.Font.Superscript = True
          If .Characters.Last.Next.Text = vbCr Then
            .Characters.Last.Next.Font.Superscript = False
            Exit Do
          End If
          .Characters.Last.Next.Text = vbNullString
        Loop
        Do While .Characters.First.Previous.Font.Superscript = True
          If .Characters.First.Previous.Text = vbCr Then
            .Characters.First.Previous.Font.Superscript = False
            Exit Do
          End If
          .Characters.First.Previous.Text = vbNullString
        Loop
        .InsertBefore "{" & i & "}"
        .Font.Superscript = True
      End With
      .Range.Cut
    End With
    Set NtRng = .Range
    With NtRng
        While .Characters.Last.Previous.Text = Chr(13)
          .Characters.Last.Previous.Text = vbNullString
        Wend
      .Collapse wdCollapseEnd
      .InsertAfter vbCr & "[" & i & "]"
      .Font.Superscript = True
      With .Paragraphs.Last.Range
        .Style = "Endnote Text"
        .Words.First.Style = "Endnote Reference"
      End With
      .Collapse wdCollapseEnd
      .Paste
    End With
  Next
  DoEvents
  StatusBar = "Deleting All Endnotes!"
  For Each eNote In .Endnotes
    eNote.Delete
  Next
  DoEvents
  With .Content
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Forward = True
      .Wrap = wdFindStop
      .Format = True
      .MatchCase = False
      .MatchWholeWord = False
      .MatchAllWordForms = False
      .MatchSoundsLike = False
      .MatchWildcards = True
      .Text = "\[([0-9]{1,})\]"
      .Font.Superscript = True
      .Replacement.Text = ""
      .Execute
    End With
    If .Find.Found Then Set NtRng = .Duplicate
    ' Find more qualifying Endnote content
    Do While .Find.Found
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
    NtRng.End = .Duplicate.Paragraphs.Last.Range.End
    ' Eliminate the 'marker' text and ensure each Endnote consists of one paragraph
    With NtRng.Find
      .MatchWildcards = True
      .Wrap = wdFindStop
      .Text = "[^11^13]{1,}"
      .Replacement.Text = "^l"
      .Execute Replace:=wdReplaceAll
      .Text = "\[([0-9]{1,})\]"
      .Replacement.Text = "^p\1"
      .Execute Replace:=wdReplaceAll
    End With
    NtRng.End = NtRng.End + 1
    NtRng.Characters.First.Delete
    j = NtRng.Words.First - 1
    DoEvents
    For i = 1 To NtRng.Paragraphs.Count
      StatusBar = "Rebuilding Endnote Reference: " & i + j
      With .Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchWholeWord = True
        .MatchWildcards = False
        .Text = "{" & i + j & "}"
        .Font.Superscript = True
        .Execute
      End With
      If .Find.Found = True Then
        Set RngNt = .Duplicate
        RngNt.Text = vbNullString
        .Endnotes.Add Range:=RngNt, Text:=""
        Set RngNt = NtRng.Paragraphs(i).Range
        With RngNt
          .End = .End - 2
          .Start = .Words(2).Start
          .Cut
        End With
        With ActiveDocument.Endnotes(i).Range
          .Collapse wdCollapseEnd
          .Paste
          If Trim(.Words.First.Text) Like "[0-9]" Then .Words.First.Text = vbNullString
          If Trim(.Words.First.Text) = "." Then .Words.First.Text = vbNullString
        End With
      End If
      DoEvents
    Next i
    NtRng.Text = vbNullString
  End With
End With
ErrExit:
Set NtRng = Nothing: Set RngNt = Nothing
StatusBar = "Done!!"
Application.ScreenUpdating = True
End Sub
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[MS MVP - Word]

Last edited by macropod; 04-13-2013 at 11:10 PM. Reason: Code revision
Reply With Quote
  #5  
Old 04-14-2013, 06:03 AM
gidmeister gidmeister is offline Repair two interspersed endnote numbering schemes? Windows 7 64bit Repair two interspersed endnote numbering schemes? Office 2007
Novice
Repair two interspersed endnote numbering schemes?
 
Join Date: Apr 2013
Posts: 4
gidmeister is on a distinguished road
Default

All fixed! Fantastic. My mother marvels that you put in this effort to help us, and thanks you profusely.
Reply With Quote
  #6  
Old 12-15-2016, 04:52 PM
jsmithbo jsmithbo is offline Repair two interspersed endnote numbering schemes? Windows 10 Repair two interspersed endnote numbering schemes? Office 2016
Novice
 
Join Date: Dec 2016
Posts: 1
jsmithbo is on a distinguished road
Default

Thanks for a great macro--it did fix the weird numbering problem I was having in my doc, but it also deleted the first word from most of the notes. Most of the original notes did not have any space or tabs between the number and the text, but the first word disappeared whether there was a space or not, and stayed when there was a tab. This doc has over 600 endnotes, so I'm hoping for an alternative to inserting tabs in all the existing notes. Thanks for any help.
Reply With Quote
  #7  
Old 12-15-2016, 07:35 PM
macropod's Avatar
macropod macropod is offline Repair two interspersed endnote numbering schemes? Windows 7 64bit Repair two interspersed endnote numbering schemes? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,533
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

The macro is designed to work with a standard endnote setup, which includes a space between the endnote reference and the endnote text. If you've deleted the endnote reference and the space following it (neither of which would occur accidentally on 'Most of the original notes'), the results can't be guaranteed. In my testing, even that only results in the first character of the endnote text being deleted, not the first word. Furthermore, the mere absence of a space after the endnote reference would not compromise the macro's workings; in fact, the missing spaces would be restored in the repaired endnotes.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Tags
renumbering endnotes

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook repair jolly Outlook 0 02-01-2012 02:01 PM
Scanpst freezes while repair wainwright Outlook 0 01-10-2012 08:14 AM
Repair two interspersed endnote numbering schemes? Looking for advice - outlook repair Nicole Crawford Outlook 1 11-27-2011 07:36 AM
endnote and import reference from word to endnote uncung Word 0 06-18-2011 08:09 AM
Corrupted PST Won't Repair stlsailor Outlook 4 09-21-2010 12:18 AM


All times are GMT -7. The time now is 11:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft