freeze references

V

vgolf

Hello to everyone,

I have to submit papers with endnotes, however the publishers insist
that the automatic feature is not used but the references are included
at the end of the document as part of the main text. Typing them
manually is tedious and creates problems when a reference is added and
all the following ones have to be renumbered. Is there a way to use the
automatic Word feature during the writing process but "freezing"
everything afterwards and just include references in the text as
requested?

Thanks
 
V

vgolf

Thanks for the effort you put into it John.

It does not seem to run right at the first time. However your reply was
very helpful, as I now get the idea of how it could be done, and that
no relevant feature of Word exists that I don't know of. I will try to
make it work.

Thank you again!
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi Vassilis:

It runs OK here. I need you to tell me exactly HOW it is failing for you.
What happens? I need the full details: this is weak code with no state or
error-checking so I need to know what's going wrong.

If you are complaining about the fact that it can't handle anything but
Arabic numbering, so am I :)

I am working on that problem, because everyone really wants the version that
can handle any kind of numbering.

Those who know VBA will tell you that's one of the things they "forgot": you
can't easily replicate numbers in VBA in the wide range of formats that
Endnotes support. This is made more interesting by the fact that the
EndNote Reference is "not" a "number", and it's "not" actually in the text
:) It's a pointer to a format. The thing that prints is inserted by Word
at output time. This, by the way, is WHY your publisher wants it as typed
text: their system can't get hold of the number either :)

I'll get there, but it will take another day or so :)

Cheers

Thanks for the effort you put into it John.

It does not seem to run right at the first time. However your reply was
very helpful, as I now get the idea of how it could be done, and that
no relevant feature of Word exists that I don't know of. I will try to
make it work.

Thank you again!

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 
V

vgolf

Hi again John,

I am a rookie with VBA so forgive me if it is something obvious.
I get the "syntax error" message. The line:
".StoryRanges(wdEndnotesStory).Copy" is highlighted.
 
V

vgolf

Guys,

I think that I am too ignorant to make a makro work. So let's get
started:

Yes, I made a copy of the document, I am not going to ruin my work.

I work on Word 2004.

And I get the same error message with Daiya's macro: Syntax Error. The
first line of the macro (Sub... ) is highlighted yellow and the line
"ActiveDocument.Range.InsertAfter vbCr & aendnote.Index & vbTab &" is
highlighted gray. What I do is open VBA editor and copy your macros in
it. Everything seems to be OK, the macro is created but then I get the
error message.

If I should go and do my homework with VBA please tell me so.

Thanks

Daiya said:
Hi Vassilis and John,

John, didn't you answer this question recently? Why did you just write a
new macro for it?

Anyhow, Vassilis, I assume/hope that you made a COPY of the doc before
running the macro?

Make a fresh copy, and try this one: John¹s previous macro, which does put
the numbers at the end, and which I recently tested in Word 2004 (I suspect
it will not work in Word X, you didn¹t mention your version).

Sub ConvertNotesToText1()
' converts endnotes to plain text
' text references as (1)
' note references as 1[tab]
' no superscript anywhere

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 = False
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


If that doesn¹t work, make yet another copy, and try the macro that youwill
find here:
http://groups.google.com/group/microsoft.public.word.docmanagement/browse_fr
m/thread/a60669f0936214e0/205fdab76e4e48eb




Hi again John,

I am a rookie with VBA so forgive me if it is something obvious.
I get the "syntax error" message. The line:
".StoryRanges(wdEndnotesStory).Copy" is highlighted.
Hi Vassilis:

It runs OK here. I need you to tell me exactly HOW it is failing for you.
What happens? I need the full details: this is weak code with no state or
error-checking so I need to know what's going wrong.

If you are complaining about the fact that it can't handle anything but
Arabic numbering, so am I :)

I am working on that problem, because everyone really wants the version that
can handle any kind of numbering.

Those who know VBA will tell you that's one of the things they "forgot": you
can't easily replicate numbers in VBA in the wide range of formats that
Endnotes support. This is made more interesting by the fact that the
EndNote Reference is "not" a "number", and it's "not" actually in the text
:) It's a pointer to a format. The thing that prints is inserted byWord
at output time. This, by the way, is WHY your publisher wants it as typed
text: their system can't get hold of the number either :)

I'll get there, but it will take another day or so :)

Cheers

On 1/10/05 9:37 AM, in article
(e-mail address removed), "vgolf"

Thanks for the effort you put into it John.

It does not seem to run right at the first time. However your reply was
very helpful, as I now get the idea of how it could be done, and that
no relevant feature of Word exists that I don't know of. I will try to
make it work.

Thank you again!

John McGhie [MVP - Word and Word Macintosh] wrote:
Hi Vassilis:

Hmmm... Not as easy as I thought :)

The short answer is "Yes. Copy the endnotes, paste as plain text atthe
bottom of the document, then delete each of the note references and replace
it with a typed number."

Not only is that a lot of work, but it's difficult because unless you work
backwards up the document, each note number will change as you delete each
endnote.

So I made a macro to do the hard work for you:


' ConvertEndNotesToText Macro
' Macro written 30 Sept 2005 by John McGhie
' Replaces Endnote references with typed numebrs and
' pastes Endnote text at end of document

Dim myDocument As Document
Dim anEndnote As Endnote
Dim myRange As Range
Dim allEndnotes As String
Dim i As Long
Set myDocument = ActiveDocument

With myDocument
.StoryRanges(wdEndnotesStory).Copy

For i = .EndNotes.Count To 1 Step -1
Set anEndnote = .EndNotes(i)
Set myRange = anEndnote.Reference
myRange.Text = Str(anEndnote.Index)
myRange.Font.Superscript = True
Next ' i
.Content.Select
With Selection
.Collapse direction:=wdCollapseEnd
.TypeParagraph
.Paste
End With
End With
End Sub


Usual caveats apply: This has not been tested extensively. I know it runs
on a Mac. I suspect it will be slow on a large document. Test it on a
COPY
of your document, because if it trashes your document: well, you accept
that
risk :)

If you don't know how to install a macro, see here:
http://word.mvps.org/MacWordNew/InstallMacroMac.htm

(Hit Refresh until you get the page, or use any other browser but Safari).

When the macro completes, you will see that the note reference has been
replaced with a typed superscript number. The endnotes themselves are
pasted at the end of the document.

The note reference numbers are striped from the Endnotes. Simply number
them yourself after the macro runs (they come out in the correct order as
they were listed in the Endnotes Pane).

Returning the numbers means a more complex macro I haven't got the energy
to
write tonight :)

Cheers

On 30/9/05 1:10 PM, in article
(e-mail address removed), "vgolf"

Hello to everyone,

I have to submit papers with endnotes, however the publishers insist
that the automatic feature is not used but the references are included
at the end of the document as part of the main text. Typing them
manually is tedious and creates problems when a reference is added and
all the following ones have to be renumbered. Is there a way to usethe
automatic Word feature during the writing process but "freezing"
everything afterwards and just include references in the text as
requested?

Thanks
 
R

Russ

Hi vgolf,
On 10/2/05 12:08 PM, in article
(e-mail address removed), "vgolf"
<[email protected]> wrote:
"ActiveDocument.Range.InsertAfter vbCr & aendnote.Index & vbTab &" is
highlighted gray. What I do is open VBA editor and copy your macros in
it.
Sometimes when I copy and paste someone else's VBA code into the editor the
lines that should remain intact get split and it confuses the VBA syntax
checker. I then must look at the next line to see if it would make sense to
be part of the previous line. If in doubt, you could also join the lines as
a test and split them again if it doesn't work. In order to quickly check
the syntax use the menu item "Debug:Compile Normal" while in the VBA editor.
If that results in no syntax errors, you can also run the code while in the
VBA editor, but make sure that you are working on a copy of your document
when testing code. The reason I mention split lines, is that; what you show
above as being highlighted in gray should also, I believe, have the next
line (aendnote.Range) as part of it on the same line.

Another tactic for repairing a line of code that chokes the syntax editor is
to manually retype it verbatim above or below and delete the old line or
"comment out" the old line with a single apostrophe character as the *very
first* character in the line. Sometimes that procedure will get rid of
invisible gremlins within the old line of code.

Good Luck
 
D

Daiya Mitchell

"ActiveDocument.Range.InsertAfter vbCr & aendnote.Index & vbTab &" is
Sometimes when I copy and paste someone else's VBA code into the editor the
lines that should remain intact get split and it confuses the VBA syntax
checker.
<snip>

Yep, that's the problem.

I *think* I just sent the macro to Vassilis inside a document. I tried to
post the second one in HTML (because I know I wound up having to retype the
entire thing) but apparently it didn't work to let copy and paste go
smoothly.

Daiya
 
V

vgolf

Thanks Daiya for taking the trouble to send me the attechment.

Indeed the problem was as stated. Everything went fine when I tested
your macros. Thanks again!

As a sidenote, a friend told me another way to do it. Insert references
in the text without numbers (e.g. Smith:2005) and the same to the
endnote which is typed at the end of the document without using the
automatic feature. When the document is complete, replace references
one by one with the respective numbers by order of appearance. It may
not be easy for many references, but it certainly works for short
texts. Anyway, I have the macro now!
 

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