Moving all the footnotes into the body

N

nutsmuggler

Hi folks. I am converting a word document into LaTeX. I need to put the
footnotes into the body, in the place of their index, between the
\footnote{HERE IS MY NOTE} tag.

I found this example

Sub MoveFootnote()
If Selection.Footnotes.Count = 1 Then
Selection.Footnotes(1).Range.Copy
Selection.Collapse direction:=wdCollapseStart
Selection.Paste
Selection.MoveRight Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End If
End Sub

This works for one single selected note, but not for all notes;
moreover, I would like to put "\footnote{" before the pasted note and
"}" after it.
Any suggestion?
Thanks in advance,
Davide
 
D

Doug Robbins - Word MVP

This should do it for all of them

Dim fnote As Footnote
For Each fnote In ActiveDocument.Footnotes
fnote.Reference.InsertBefore "\footnote{" & fnote.Range.Text & "}"
Next fnote
For Each fnote In ActiveDocument.Footnotes
fnote.Reference.Delete
Next fnote


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
N

nutsmuggler

Doug Robbins - Word MVP ha scritto:
This should do it for all of them

Dim fnote As Footnote
For Each fnote In ActiveDocument.Footnotes
fnote.Reference.InsertBefore "\footnote{" & fnote.Range.Text & "}"
Next fnote
For Each fnote In ActiveDocument.Footnotes
fnote.Reference.Delete
Next fnote
Wow, impressive, simple and elegant. Thank you very much!
There are just a couple of little problems (minor ones):
1) the reference do not disappear; what I get is
ex: This is my text, etc1.\footnote{This is my note}
I guess the "1." is the refernece number that was in the note... How to
get rid of it?
2) Do you think it could be possible to assign a style to these notes
inserted in the text? I would like to have this "\footnote{mynote}"
text in a distinct character style , so I'll be able to distinguish it
from the rest of the text when debugging...
Cheers,
Davide
 
D

Doug Robbins - Word MVP

I don't know where the 1. comes from. It is not the footnote reference (the
superscript number that is inserted into the text at the location to which
the footnote applies and is the number that precedes the text of the
footnote). I can only assume that it has been entered from the keyboard.
The following modified macro will apply bold formatting to the text that is
inserted and change the font color to Red:

Dim fnote As Footnote
Dim frange As Range
For Each fnote In ActiveDocument.Footnotes
Set frange = fnote.Reference
fnote.Reference.InsertBefore "\footnote{" & fnote.Range.Text & "}"
frange.Font.Bold = True
frange.Font.Color = wdColorRed
Next fnote
For Each fnote In ActiveDocument.Footnotes
fnote.Reference.Delete
Next fnote


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
N

nutsmuggler

Ach, you were right, I had put the reference myself for debugging
purposes.
Anyway, this is my final script:

Sub notesToBody()
'
' noteInTesto Macro
Dim fnote As Footnote
Dim frange As Range
For Each fnote In ActiveDocument.Footnotes
Set frange = fnote.Reference
fnote.Reference.InsertBefore "\footnote{" & fnote.Range.Text &
"}"
frange.Style = ActiveDocument.Styles("footnote")
Next fnote
For Each fnote In ActiveDocument.Footnotes
fnote.Reference.Delete
Next fnote
End Sub

As you see, I have put a custom style to the notes, just to find them
easily later (I have a 70 pg document to process)
Thanks a million again,
Davide
 
D

Doug Robbins - Word MVP

Yes, better to use a style as then you can just re-define the style so that
the text to which it has been applied does not stand out from the rest of
the text.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top