VBA to insert reference page into MS word endnote -


book endnotes forgo superscript numbers page numbers. e.g., instead of

abe lincoln assassinated pistol.^33                    : 33. single-shot derringer pistol. 

books several authors write

abe lincoln assassinated pistol.                    : page 297. abe lincoln shot single-shot derringer pistol. 

word doesn't have feature, believe have macro. came simple code below loops through of endnotes , adds

"page ???. " 

before each endnote, "???" need to correctly insert page number in manuscript citation's located on?

sub redefineexistingendnotes()     dim fn endnote     each fn in activedocument.endnotes         fn.range.paragraphs(1).range.font.reset         fn.range.paragraphs(1).range.characters(1).insertbefore "page" & "???" & " - "     next fn end sub 

try below vba code:

sub insertpagenumberforendnotes()  dim endnotecount integer dim curpagenumber integer  if activedocument.endnotes.count > 0  endnotecount = 1 activedocument.endnotes.count  selection.goto what:=wdgotoendnote, which:=wdgotoabsolute, count:=endnotecount curpagenumber = selection.information(wdactiveendpagenumber) activedocument.endnotes(endnotecount).range.select activedocument.application.selection.collapse (wdcollapsedirection.wdcollapsestart) activedocument.application.selection.paragraphs(1).range.characters(1).insertbefore "page " & cstr(curpagenumber) & " - "   next end if  end sub 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -