![]() |
|
|
|
#1
|
||||
|
||||
|
Hi Ken, FWIW, does the following achieve what you're after? Code:
Sub ExportEndNotes()
Application.ScreenUpdating = False
Dim Rng As Range, DocSrc As Document, DocTgt As Document, i As Long, StrRef As String
Set DocSrc = ActiveDocument
With DocSrc
'Unlink endnote/footnote cross-references
For i = .Fields.Count To 1 Step -1
If .Fields(i).Type = wdFieldNoteRef Then .Fields(i).Unlink
Next
'Process all endnotes
For i = 1 To .Endnotes.Count
'First, process the endnote ref in the document body
Set Rng = .Endnotes(i).Reference
With Rng
.Collapse wdCollapseStart
'To get the actual reference text, we need to cross-reference it!
.InsertCrossReference wdRefTypeEndnote, wdEndnoteNumberFormatted, i, False, False
.End = .End + 1
StrRef = .Text
.Fields(1).Unlink
End With
'Second, process the endnote ref in the endnote
Set Rng = .Endnotes(i).Range.Paragraphs.First.Range.Words.First
With Rng
If .Characters.Last Like "[ " & vbTab & "]" Then .End = .End - 1
'Overwrite the existing endnote reference
.Text = StrRef
End With
Next
'Give Word a chance to do its housekeeping
DoEvents
'Create the output document
Set DocTgt = Documents.Add
'Replicate the endnotes in the body of the output document
DocTgt.Range.FormattedText = .StoryRanges(wdEndnotesStory).FormattedText
'Delete the endnotes from the source document
For i = .Endnotes.Count To 1 Step -1
.Endnotes(i).Delete
Next
End With
Set Rng = Nothing: Set DocTgt = Nothing: Set DocSrc = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
||||
|
||||
|
Hi Alan,
With the first macro I posted, it's as simple as changing: .Text = i to: .Text = i & ". "
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
I've been rattling every cage I can find for some help in copying endnotes in Word for Mac 2011. Stephan Bloom was a big help in getting me through the first step but now the second step is eluding me.
What I want to do is copy the endnotes from a chapter to a separate document and remove them from the original while retaining the superscript numbers in the original and providing a corresponding number in the deleted/copied.moved endnotes. Word will not let me simply copy endnotes. An error message pops up saying it is an invalid action. The macro Bloom sent resolves part of the problem. It removes the superscripts from the endnotes and replaces them with regular numbers which can then be copied to a new document. The problem is the revised list looks like this: 1 Now is the time ... My aim is to make it look like this: 1. Now is the time ... 2. For all good men ... And so on through the list of footnotes. Does anyone have any idea how to create a macro to do this? The second problem is the Bloom macro replaces all the superscripted references. Where before it looked like this: Now is the time(superscript 1) It comes out like this: Now is the timea1a... That means going through the entire document and replace the "a...a" with the appropriate superscript. I think I I've found a workaround here,. if I work in Master Document mode the document appears as the original with all the endnote references in place and properly superscripted. It also removes the endnotes. I've only tried this with a couple of documents but it is encouraging. The problem remains with formatting the copied endnotes. Any and all help would be appreciated. |
|
#4
|
||||
|
||||
|
Hi Ken,
I've posted four macros for you to try in this (merged) thread. Except for some comments re the first one, I've never had any feedback from you as to whether they worked and, if not, what the issue was.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
Quote:
Maybe I missed some, but I've seen only two. My email referred to the first one which begins: Sub ExtractEndNotes() Application.ScreenUpdating = False Dim Rng As Range, i As Long, Doc As Document With ActiveDocument I tried the second one but it generated an error message saying something to the effect that it was not working and needed to be debugged. I let the debugger run for quite a long time, but it never produced any results. I'm far from an expert and I have no idea how to perform a debugging process except to let the process run. I'd be delighted to re-try any of your suggestions and promptly report the results. Ken |
|
#6
|
||||
|
||||
|
If you get a 'debug' error, note what the error message says and, when you press 'debug', which code line is highlighted. If you report those details, we may be able to deal with whatever the issue is.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
Paul
This is the macro I'm trying to run: Code:
Sub test()
'Macro created 29/09/99 by Doug Robbins to replace endnotes with textnotes at end of document
' and replace the endnote reference in the body of the document with a superscript number.
'
Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
ActiveDocument.Range.InsertAfter vbCr & aendnote.Index & vbTab & 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
End Sub
Run time error '4605' This method or property is not available because the object spans a frame or note boundary Note that macro was written in 1999, which was long before Word for Mac 2011. But what it wants to accomplish is exactly what I'm trying to do. I very much appreciate your time. Ken Last edited by macropod; 09-14-2012 at 04:05 PM. Reason: Added code tags & formatting |
|
#8
|
||||
|
||||
|
We know about the problems with Doug's code, which is why I've posted four different macros for you to try. It appears you've only ever tried the first one. The code in post #15 (https://www.msofficeforums.com/word/...html#post28578), especially, shouldn't generate any of those errors.
Of course, without knowing exactly what's in your endnotes, it's possible the error is because there's, say, a frame in one of them - as suggested by the error message.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing footnotes to endnotes | Sarah | Word | 3 | 04-27-2017 08:55 PM |
Copying endnotes
|
kenglade | Word | 4 | 12-03-2011 01:26 PM |
| Index entries in endnotes | perhj | Word | 0 | 06-19-2011 09:28 AM |
how do I change fonts for endnotes of word 2007?
|
Brent | Word | 5 | 02-01-2011 03:15 PM |
| Separating accounts | aka252 | Outlook | 0 | 02-23-2006 07:55 PM |