#1
|
|||
|
|||
How to change superscript footnotes into genuine Word footnotes
I converted a book from PDF to DOC using Abode Acrobat. The DOC is attached.
I would like to know how to change the superscript footnotes into genuine Word footnotes. The attachment is just the first page of the book. The book is quite long. I hope there is a blanket fix or a fix that involves a few clicks for each footnote. Thank you. |
#2
|
||||
|
||||
When documents with footnotes are converted to Word from other programs, the footnotes may come across as plain text, with the footnote links simply showing as superscripted numbers or numbers enclosed in brackets. The following macro processes such footnotes in a selected range, turning them into 'proper' Word footnotes, retaining their formatting (eg bold/italic/underline).
The macro assumes: • The selected range contains the footnotes to be converted, with the first footnote number being, at most, enclosed in square brackets, thus [#], followed by a space. Comments in the code indicate where to make changes to suit other scenarios. If the footnotes are scattered throughout the document, rather than at the end, for example, the code will process the selected footnote text on each page • you’ll be using the 'Footnote Text' style footnotes. If not, you can simply change it in the line: .Style = "Footnote Text" • each footnote consists of a single paragraph. If you have any multi-paragraph footnotes, you can get around that issue by changing their internal paragraph markers to line feeds (i.e. Shift-Enter) before running the macro. The macro shows its progress on the status bar. Code:
Sub ReLinkFootNotes() Dim i As Long, j As Long, k As Long, l As Long, FtRng As Range Application.ScreenUpdating = False With ActiveDocument Set FtRng = Selection.Range With FtRng .Style = "Footnote Text" With .Find .ClearFormatting .Replacement.ClearFormatting ' Change '[' and ']' on the next line to whatever is appropriate if the selected ' footnotes' numbers are enclosed in characters other than square brackets ' (e.g. .Text = "([0-9]{1,})" if there are no brackets) .Text = "\[([0-9]{1,})\]" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindStop .Format = True ' Delete the next line if the footnote references are not superscripted. .Font.Superscript = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True .Execute Replace:=wdReplaceAll End With k = .Paragraphs(1).Range.Words(1) - 1 j = k l = ActiveDocument.Footnotes.Count - k For i = 1 To .Paragraphs.Count If .Paragraphs(i).Range.Words(1) = j + 1 Then j = j + 1 End If Next i End With For i = k + 1 To j StatusBar = "Finding Footnote Location: " & i + l With .Content.Find ' Change '"[" & i & "]"' string on the next line to whatever is appropriate ' if the in-line references are not enclosed in square brackets .Text = "[" & i & "]" ' Delete/comment out the next line if not applicable .Font.Superscript = True .MatchWholeWord = True .MatchWildcards = False .Execute If .Found = True Then .Parent.Select With Selection .Delete .Footnotes.Add Range:=Selection.Range, Text:="" End With End If End With Next i With FtRng For i = k + 1 To j StatusBar = "Transferring Footnote: " & i + l With .Paragraphs(1).Range .Cut With ActiveDocument.Footnotes(i + l).Range .Paste .Words(1).Delete .Characters.Last.Delete End With End With Next i On Error Resume Next End With Set FtRng = Nothing End With Application.ScreenUpdating = True End Sub • Take the selected footnote paragraphs, strip off any enclosing characters from the numbers. • Apply the footnote style to the selected footnote paragraphs • Count the number of bookmarked paragraphs with sequential numbers, starting at the first paragraph’s footnote number. • Find the corresponding footnote numbers in the document • Turn the matched numbers into empty footnotes • Cut & Paste the footnote paragraphs into the empty footnotes • Delete the first word (footnote number) and last character (duplicate para mark) from each footnote. For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you, but when I run the macro it says Run-time error '13': Type mismatch
I then clicked "debug" and it highlighted the following line in yellow: k = .Paragraphs(1).Range.Words(1) - 1 |
#4
|
||||
|
||||
Did you select the 'footnotes' you want to process? Note the specification in my previous post:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Unfortunately, it doesn't work for me. Here are the steps I took:
Opened Microsoft Word 2010 Clicked Macros In the Macro name field I typed Macro2017 Clicked Create Copied and pasted the code from this forum into the window Exited out Highlighted all four notes at the bottom of Book.doc using shift key Clicked Macros Clicked Run for Macro2017 Message pops up saying Run-time error '5941': The requested member of the collection does not exist. |
#6
|
||||
|
||||
That is not the process advised in the link I posted. The macro is already complete; your process embeds my macro inside another...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
I have tried many approaches and cannot get it to work. In my most recent attempt, footnote #1 disappears when I run the macro.
Do you have MS Word 2010? If so, could you maybe type the exact steps you took? I'm sorry but I need it really simple. For example, "1. Click Macros, 2. Click Create, etc" Also, can you attach Book.doc to your next post so I can see what the corrected file looks like? Thank you! |
#8
|
||||
|
||||
The real issue, IMHO, is whether you followed the PC macro installation & usage instructions in the link I gave you.
Document with macro & processed document attached. As per the notes in the macro code, all you (still) need to do is change: .Text = "\[([0-9]{1,})\]" to: .Text = "([0-9]{1,})"
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Clearly it does work. That is amazing.
I will set aside some time and try to follow the "PC macro installation & usage instructions" very carefully. |
#10
|
|||
|
|||
Well, I cannot get it to work. I spent hours trying different methods.
It is obvious I am doing something wrong. When you say "select the footnotes you want to process," do you mean highlight them using the shift key? Then click Run? |
#11
|
||||
|
||||
Quote:
Did you make the required changes to the code? I have mentioned the need for this repeatedly.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
Hello
Was it supposed to work if footnotes are dispersed/disseminated in the document ? I mean when each footnote is located at the bottom of the page where it's called from - because that's what I often (always) notice when I convert PDF documents to Word documents, and that's what I was expecting to find in this post. Here, the code doesn't work when 'footnotes' paragraphs are selected with the Ctrl key (even in the Knounte29 sample text: only the last selected 'footnote' paragraph is correctly changed to genuine footnote). If a coder could fix this, I would be very grateful. Bernard Sorry, but should I create a new thread for this ? |
#13
|
||||
|
||||
Did you compare the attachments in posts #1 & #8? You'll see from them that, if the instructions in post #2 are followed exactly, the process works as described.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#14
|
|||
|
|||
Paul, thanks for replying
I did follow your explainations, but in the test file sent by Knoute29, footnotes are gathered together, and yes, it works fine if selected in a row (altogether). But when notes are disseminated (scattered?) in the text (as they are in my converted files), i have to select them with the Ctrl key, and in that case, i found that it doesn't work Am I right ? |
#15
|
|||
|
|||
Below are the code and sample text used :
Did I made a mistake ? Code:
Sub ReLinkFootNotes() Dim i As Integer, j As Integer, k As Integer, l As Integer, FtRng As Range Application.ScreenUpdating = False With ActiveDocument Set FtRng = Selection.Range With FtRng .Style = "Note de bas de page" With .Find .ClearFormatting .Replacement.ClearFormatting ' Change '[' and ']' on the next line to whatever is appropriate if the selected ' footnotes' numbers are enclosed in characters other than square brackets .Text = "([0-9]{1;})" .Replacement.Text = "\1" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True .Execute Replace:=wdReplaceAll End With k = .Paragraphs(1).Range.Words(1) - 1 j = k l = ActiveDocument.Footnotes.Count - k For i = 1 To .Paragraphs.Count If .Paragraphs(i).Range.Words(1) = j + 1 Then j = j + 1 End If Next i End With For i = k + 1 To j StatusBar = "Finding Footnote Location: " & i + l With .Content.Find ' Change '"[" & i & "]"' string on the next line to whatever is appropriate ' if the in-line references are not enclosed in square brackets .Text = i ' Delete/comment out the next line if not applicable .Font.Superscript = True .MatchWholeWord = True .MatchWildcards = False .Execute If .Found = True Then .Parent.Select With Selection .Delete .Footnotes.Add Range:=Selection.Range, Text:="" End With End If End With Next i With FtRng For i = k + 1 To j StatusBar = "Transferring Footnote: " & i + l With .Paragraphs(1).Range .Cut With ActiveDocument.Footnotes(i + l).Range .Paste .Words(1).Delete .Characters.Last.Delete End With End With Next i On Error Resume Next End With Set FtRng = Nothing End With Application.ScreenUpdating = True End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word footnotes and track changes problem | Carnegie | Word | 14 | 03-13-2017 01:31 AM |
Convert manual cross references in footnotes to other footnotes to automatic cross references | ghumdinger | Word VBA | 7 | 11-20-2014 11:47 PM |
word 2007 - footnotes and text box | glggluig | Word | 1 | 08-10-2014 04:09 AM |
Corrupted footnotes in Word | mythander889 | Word | 12 | 09-11-2012 03:58 PM |
Can Word automatically update footnotes? | gib65 | Word | 2 | 08-15-2011 01:46 PM |