Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2019, 03:05 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default Help needed with moving footnotes

Hi, my first post and I am stymied by this problem!



I am in the process of writing an incredibly large book (currently 270,000 words) on the history of a glassworks. While writing this it is essential to keep track of the references and sources, hence the need for hundreds of footnotes, although some will be removed when the final edit is performed.

When I started writing, I noticed that the footnotes were being included as a single word count, which I wanted to avoid. The conventional position for the footnote is immediately after the full stop in a sentence, although sometimes they are used in mid-sentence.

To prevent this I decided to try positioning them immediately before the stop, but now I would like to move them all back to the conventional place.

OK, so I know that ^fn (footnote special character) can be used within the Find/Replace dialogue, however, ^fn cannot be used in the 'Replace' field. So, simplistically:
Find: ^fn.
Replace with: .^fn

is invalid.

Can anyone suggest a solution? Any help is much appreciated!

David
Reply With Quote
  #2  
Old 06-05-2019, 05:54 PM
macropod's Avatar
macropod macropod is offline Help needed with moving footnotes Windows 7 64bit Help needed with moving footnotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

The following macro ensures all Footnote & Endnote references are placed after any applicable adjacent punctuation marks. Any preceding space characters are also deleted.
Code:
Sub FootnoteEndnoteFix()
Application.ScreenUpdating = False
Dim FtNt As Footnote, EndNt As Endnote, Rng As Range
With ActiveDocument
  For Each FtNt In .Footnotes
    Set Rng = FtNt.Reference
    With Rng
      'Eliminate any spaces before the footnote
      While .Characters.First.Previous.Text = " "
        .Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the footnote/punctuation, as applicable
      Select Case .Characters.Last.Next
        Case ".", ",", "!", "?", ":", ";"
        .InsertBefore .Characters.Last.Next
        .Characters.Last.Next.Delete
      End Select
    End With
  Next
  For Each EndNt In .Endnotes
    Set Rng = EndNt.Reference
    With Rng
      'Eliminate any spaces before the endnote
      While .Characters.First.Previous.Text = " "
        .Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the endnote/punctuation, as applicable
      Select Case .Characters.Last.Next
        Case ".", ",", "!", "?", ":", ";"
        .InsertBefore .Characters.Last.Next
        .Characters.Last.Next.Delete
      End Select
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-06-2019, 01:34 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

Many thanks Paul, that worked like a dream.

Just one slight problem is where a sentence finishes with a single- or double-quote mark:

... and "this is the end of the sentence123."

becomes:

... and "this is the end of the sentence.123"

So I think the code needs to take into account other punctuation marks to make it more universal:

Quote '
Speech "

I doubt that other marks would feature.

Once again, I really appreciate the time you've taken

Last edited by Last Chance; 06-06-2019 at 03:45 AM.
Reply With Quote
  #4  
Old 06-06-2019, 03:44 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

UPDATE:
I modified this line:
Code:
        Case ".", ",", "!", "?", ":", ";", """, " '"
It appears to work, except for the single quote where a space keeps getting inserted.
Reply With Quote
  #5  
Old 06-06-2019, 06:24 AM
macropod's Avatar
macropod macropod is offline Help needed with moving footnotes Windows 7 64bit Help needed with moving footnotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Quote:
Originally Posted by Last Chance View Post
UPDATE:
I modified this line:
Code:
        Case ".", ",", "!", "?", ":", ";", """, " '"
It appears to work, except for the single quote where a space keeps getting inserted.
That's because your code has a space before the single quote.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 06-06-2019, 07:09 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

Yes, because it automatically inserts it. I can't seem to make it understand I don't want the space
Reply With Quote
  #7  
Old 06-06-2019, 07:12 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

As soon as I "click away" with the mouse, the space just appears. I also pasted the code into Notebook and pasted it back, but it simply inserts the space. Confusing!
Reply With Quote
  #8  
Old 06-06-2019, 07:15 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

I know why: it's interpreting the single quote as the beginning of a 'Comment and forcing the space.

Last edited by Last Chance; 06-06-2019 at 02:30 PM.
Reply With Quote
  #9  
Old 06-06-2019, 04:05 PM
macropod's Avatar
macropod macropod is offline Help needed with moving footnotes Windows 7 64bit Help needed with moving footnotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

That's happening because:
Case ".", ",", "!", "?", ":", """, " '", ";"
should be:
Case ".", ",", "!", "?", ":", """", "'", ";"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 06-07-2019, 12:59 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

Paul, I know that, but if I type "'" in the Visual Basic Editor, the end result is " '" - it is the editor that's adding the space and there's no way I can prevent this. As mentioned in my previous reply, VBE is interpreting this to be a Comment and forcing the space.

If there is no other way around this then I can perform a 'Find' in Word and go through it instance by instance, but it's a bit tedious!

Thanks again, your help has already saved me an incalculable amount of time.
Reply With Quote
  #11  
Old 06-07-2019, 04:34 AM
macropod's Avatar
macropod macropod is offline Help needed with moving footnotes Windows 7 64bit Help needed with moving footnotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

You need to look more closely at what I posted. It works.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 06-07-2019, 07:35 AM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

I see - the double-quotes surrounding the double double-quotes and (I assume) the order of the definitions. Not everyone's eyes can pick that up immediately!

But while it worked for the double-quotes, I still can't get it to work for the single quote (') - I pasted your line into the script so there was no ambiguity.

Any ideas?
Reply With Quote
  #13  
Old 06-07-2019, 11:20 AM
gmaxey gmaxey is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

This adaptation of Paul's code seems to work to move the after a " ' and .
Code:
Sub FootnoteEndnoteFix()
Application.ScreenUpdating = False
Dim FtNt As Footnote, EndNt As Endnote, Rng As Range
  With ActiveDocument
    For Each FtNt In .Footnotes
      Set Rng = FtNt.Reference
      While Rng.Characters.First.Previous.Text = " "
        Rng.Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the footnote/punctuation, as applicable
      Do
        Set Rng = FtNt.Reference
        Select Case Rng.Characters.Last.Next
          Case ".", ",", "!", "?", ":", ";", "'", """", ChrW(8221), ChrW(8217)
            Rng.InsertBefore Rng.Characters.Last.Next
            Rng.Characters.Last.Next.Delete
          Case Else
            Exit Do
        End Select
      Loop
    Next
    For Each EndNt In .Endnotes
      Set Rng = FtNt.Reference
      While Rng.Characters.First.Previous.Text = " "
        Rng.Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the footnote/punctuation, as applicable
      Do
        Set Rng = FtNt.Reference
        Select Case Rng.Characters.Last.Next
          Case ".", ",", "!", "?", ":", ";", "'", """", ChrW(8221), ChrW(8217)
            Rng.InsertBefore Rng.Characters.Last.Next
            Rng.Characters.Last.Next.Delete
          Case Else
            Exit Do
        End Select
      Loop
    Next
  End With
  Application.ScreenUpdating = True
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #14  
Old 06-07-2019, 02:01 PM
Last Chance Last Chance is offline Help needed with moving footnotes Windows 10 Help needed with moving footnotes Office 2007
Novice
Help needed with moving footnotes
 
Join Date: Jun 2019
Location: Bromsgrove, UK
Posts: 17
Last Chance is on a distinguished road
Default

Many thanks Greg, that's fixed it.

One Happy Bunny
Reply With Quote
  #15  
Old 06-07-2019, 05:57 PM
macropod's Avatar
macropod macropod is offline Help needed with moving footnotes Windows 7 64bit Help needed with moving footnotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Greg's:
Case ".", ",", "!", "?", ":", ";", "'", """", ChrW(8221), ChrW(8217)
is functionally the same as:
Case ".", ",", "!", "?", ":", ";", "'", """", "’", "”"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed with moving footnotes How to change superscript footnotes into genuine Word footnotes Knounte29 Word VBA 41 01-16-2020 04:48 PM
creating manuscript w/footnotes from separate documents containing chapters with footnotes-word 2010 Dottie Publisher 0 02-19-2017 03:18 PM
Convert manual cross references in footnotes to other footnotes to automatic cross references ghumdinger Word VBA 7 11-20-2014 11:47 PM
Help needed with moving footnotes Moving cell content without moving borders & shading? unittwentyfive Excel 1 10-25-2013 12:56 PM
Help needed with moving footnotes Moving formula range multiple cells when moving sum over one cell FraserKitchell Excel 4 02-26-2010 10:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:16 AM.


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