embedded endnotes - repost

B

bob adler

Following my query in Document Management newsgroup, Doug
Robbins offered this good macro to unembed endnotes and
to change the number preceding each endnote from
superscript to regular font:

Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range
aendnote.Reference.InsertBefore "a" &
aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

It works but there is an unintended result of the macro:
It not only removes the superscript format from the
number preceding the endnote, it removes all the
formatting (italics, etc.)from within the endnotes
themselves.

Can the macro be modified to remove just the superscript
formatting of the number preceding each endnote while
leaving the formating in the endnote itself, while
unembedding the endnotes?

Thanks,
bob adler
 
D

Doug Robbins - Word MVP

Hi Bob,

Try the following modification

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.FormattedText.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range.FormattedText

of this bit of the code

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
B

bob adler

Hi, Doug:
I think I did what you suggested (see below) but there
was no change in the result. Here's what the macro looks
like now:
'Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.FormattedText.InsertAfter
vbCr & aendnote.Index & ". " &
aendnote.Range.FormattedText
aendnote.Reference.InsertBefore "a" &
aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Is that right?

Thanks,
Bob Adler
-----Original Message-----
Hi Bob,

Try the following modification

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.FormattedText.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range.FormattedText

of this bit of the code

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Following my query in Document Management newsgroup, Doug
Robbins offered this good macro to unembed endnotes and
to change the number preceding each endnote from
superscript to regular font:

Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range
aendnote.Reference.InsertBefore "a" &
aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

It works but there is an unintended result of the macro:
It not only removes the superscript format from the
number preceding the endnote, it removes all the
formatting (italics, etc.)from within the endnotes
themselves.

Can the macro be modified to remove just the superscript
formatting of the number preceding each endnote while
leaving the formating in the endnote itself, while
unembedding the endnotes?

Thanks,
bob adler

.
 
D

Doug Robbins - Word MVP

Try this method:

Dim aendnote As Endnote, docend As Range
For Each aendnote In ActiveDocument.Endnotes
aendnote.Range.Copy
ActiveDocument.Range.InsertAfter vbCr & aendnote.Index & ". "
Set docend = ActiveDocument.Range
docend.Collapse wdCollapseEnd
docend.Paste
docend.Font.Size = ActiveDocument.Styles("Endnote Text").Font.Size
aendnote.Reference.InsertBefore "a" & aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
bob adler said:
Hi, Doug:
I think I did what you suggested (see below) but there
was no change in the result. Here's what the macro looks
like now:
'Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.FormattedText.InsertAfter
vbCr & aendnote.Index & ". " &
aendnote.Range.FormattedText
aendnote.Reference.InsertBefore "a" &
aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Is that right?

Thanks,
Bob Adler
-----Original Message-----
Hi Bob,

Try the following modification

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.FormattedText.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range.FormattedText

of this bit of the code

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Following my query in Document Management newsgroup, Doug
Robbins offered this good macro to unembed endnotes and
to change the number preceding each endnote from
superscript to regular font:

Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range
aendnote.Reference.InsertBefore "a" &
aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

It works but there is an unintended result of the macro:
It not only removes the superscript format from the
number preceding the endnote, it removes all the
formatting (italics, etc.)from within the endnotes
themselves.

Can the macro be modified to remove just the superscript
formatting of the number preceding each endnote while
leaving the formating in the endnote itself, while
unembedding the endnotes?

Thanks,
bob adler

.
 
B

bob adler

That looks great, Doug. I thought I had a problem with
it when I ran it with my (default) Track Changes
selected. The macro then put the letter "a" before and
after the endnote reference number in the text, and left
them there even after I accepted the changes.
It looks great when I run it without the Track Changes on
and it seems to work whether I'm in Normal or Print
Layout view.
Thanks, again.
Bob Adler
-----Original Message-----
Try this method:

Dim aendnote As Endnote, docend As Range
For Each aendnote In ActiveDocument.Endnotes
aendnote.Range.Copy
ActiveDocument.Range.InsertAfter vbCr & aendnote.Index & ". "
Set docend = ActiveDocument.Range
docend.Collapse wdCollapseEnd
docend.Paste
docend.Font.Size = ActiveDocument.Styles ("Endnote Text").Font.Size
aendnote.Reference.InsertBefore "a" & aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Hi, Doug:
I think I did what you suggested (see below) but there
was no change in the result. Here's what the macro looks
like now:
'Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.FormattedText.InsertAfter
vbCr & aendnote.Index & ". " &
aendnote.Range.FormattedText
aendnote.Reference.InsertBefore "a" &
aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Is that right?

Thanks,
Bob Adler
-----Original Message-----
Hi Bob,

Try the following modification

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.FormattedText.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range.FormattedText

of this bit of the code

For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
"bob adler" <[email protected]>
wrote
in message
Following my query in Document Management newsgroup, Doug
Robbins offered this good macro to unembed endnotes and
to change the number preceding each endnote from
superscript to regular font:

Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr &
aendnote.Index & ". " & aendnote.Range
aendnote.Reference.InsertBefore "a" &
aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.Font
.Superscript = True
End With
With Selection.Find
.Text = "(a)([0-9]{1,})(a)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

It works but there is an unintended result of the macro:
It not only removes the superscript format from the
number preceding the endnote, it removes all the
formatting (italics, etc.)from within the endnotes
themselves.

Can the macro be modified to remove just the superscript
formatting of the number preceding each endnote while
leaving the formating in the endnote itself, while
unembedding the endnotes?

Thanks,
bob adler


.

.
 

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