![]() |
|
#1
|
||||
|
||||
![]() Try: Code:
Sub EndNoteFootNotePunctCheck() Application.ScreenUpdating = False Dim i As Long With ActiveDocument 'Process EndNotes For i = .Endnotes.Count To 1 Step -1 Call SetPunctAfter(.Endnotes(i).Reference) Next 'Process FootNotes For i = .Footnotes.Count To 1 Step -1 Call SetPunctAfter(.Footnotes(i).Reference) Next 'Process EndNote/FootNote References For i = .Range.Fields.Count To 1 Step -1 With .Range.Fields(i) If .Type = wdFieldNoteRef Then Call SetPunctAfter(.Result) End If End With Next End With Application.ScreenUpdating = True End Sub Sub SetPunctAfter(Rng As Range) With Rng.Duplicate .Collapse wdCollapseStart 'Eliminate any spaces before the footnote reference Do While .Characters.First.Previous Like "[ " & Chr(160) & "]" .Characters.First.Previous.Text = vbNullString Loop 'Find the preceding puctuation, bracket, etc. Do While .Characters.First.Previous Like "[!0-9A-Za-z" & vbCr & Chr(11) & vbTab & "]" If .Characters.First.Previous.Fields.Count = 1 Then If .Characters.First.Previous.Fields(1).Result = "]" Then .Start = .Characters.First.Previous.Fields(1).Result.Start + 1 Else Exit Do End If End If If .Characters.First.Previous.ContentControls.Count = 1 Then If .Characters.First.Previous.ContentControls(1).Range.Text = "]" Then .Start = .Characters.First.Previous.ContentControls(1).Range.Start + 1 Else Exit Do End If End If .Start = .Start - 1 Loop 'Swap the footnote/punctuation, as applicable If .Start <> Rng.Start Then Rng.Collapse wdCollapseEnd .Cut Rng.Paste End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#2
|
|||
|
|||
![]()
Hi Macropod, thank you so much for the new code, I've run it on a 153 page contract today and all looking good - is there a way to tell the code to ignore "quotes", apostrophe's and (parenthesis) as its moving the Footnote Reference in the wrong place, it only needs to move for periods, semi-colons, colons and question marks
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
emblaw | Word | 4 | 12-08-2020 06:23 AM |
![]() |
KDuncan | Word | 6 | 04-28-2020 12:14 AM |
![]() |
michaelbriordan | Word | 3 | 06-17-2015 10:12 AM |
![]() |
bearligirl89 | Word | 3 | 11-20-2013 03:33 PM |
![]() |
jimgard | Word | 1 | 07-23-2013 11:47 AM |